<template><div><h2 id="beta版本更新日志" tabindex="-1"><a class="header-anchor" href="#beta版本更新日志"><span>BETA版本更新日志</span></a></h2>
<h2 id="v2-2-2-beta" tabindex="-1"><a class="header-anchor" href="#v2-2-2-beta"><span>v2.2.2-beta</span></a></h2>
<p>发布时间 2022/6/27</p>
<h3 id="升级版本" tabindex="-1"><a class="header-anchor" href="#升级版本"><span>升级版本</span></a></h3>
<p>逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.2.2-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug-修复" tabindex="-1"><a class="header-anchor" href="#bug-修复"><span>BUG 修复</span></a></h3>
<ol>
<li>修复 Grid 表格当字段值为<code v-pre>0</code>时无法显示问题</li>
</ol>
<h2 id="v2-2-1-beta" tabindex="-1"><a class="header-anchor" href="#v2-2-1-beta"><span>v2.2.1-beta</span></a></h2>
<p>发布时间 2022/6/26</p>
<h3 id="升级版本-1" tabindex="-1"><a class="header-anchor" href="#升级版本-1"><span>升级版本</span></a></h3>
<p>逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.2.1-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能" tabindex="-1"><a class="header-anchor" href="#新增功能"><span>新增功能</span></a></h3>
<p><strong>1. 日夜模式切换支持多开场景 (<a href="https://github.com/jqhph/dcat-admin/pull/1672" target="_blank" rel="noopener noreferrer">#1672 by @ReedSun</a>)</strong></p>
<p><strong>2. 表单增加 <code v-pre>override</code> 方法实现文件覆盖 (<a href="https://github.com/jqhph/dcat-admin/pull/1706" target="_blank" rel="noopener noreferrer">#1706 by @laradocs</a>)</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'file'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">override</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">image</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'img'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">override</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3. 支持嵌套资源型控制器 (<a href="https://github.com/jqhph/dcat-admin/pull/1725" target="_blank" rel="noopener noreferrer">#1725 by @lddtime</a>)</strong></p>
<p><strong>4. 支持在array/hasMany表单中使用when控制表单显示功能 （<a href="https://github.com/jqhph/dcat-admin/pull/1776" target="_blank" rel="noopener noreferrer">#1776 by @rainhon</a>)</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">array</span><span class="token punctuation">(</span><span class="token variable">$column</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">radio</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'radio'</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">when</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Form</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'text1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">            <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'text2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">            <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'text3'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">when</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Form</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">editor</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'editor'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">when</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Form</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">image</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'image'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">options</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">default</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5. 页面组件 <code v-pre>tab</code> 刷新后可选中对应选项 (<a href="https://github.com/jqhph/dcat-admin/pull/1689" target="_blank" rel="noopener noreferrer">#1689 by @iljalukin</a>)</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Widgets<span class="token punctuation">\</span>Tab</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$tab</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Tab</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$tab</span><span class="token operator">-></span><span class="token function">add</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'tab1'</span><span class="token punctuation">,</span> <span class="token operator">...</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'id1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token variable">$tab</span><span class="token operator">-></span><span class="token function">add</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'tab2'</span><span class="token punctuation">,</span> <span class="token operator">...</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'id2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6. 页面组件 <code v-pre>table</code> 没有数据时显示 <code v-pre>No data.</code> (<a href="https://github.com/jqhph/dcat-admin/pull/1678" target="_blank" rel="noopener noreferrer">#1678 by @shacky</a>)</strong></p>
<h3 id="bug-修复-1" tabindex="-1"><a class="header-anchor" href="#bug-修复-1"><span>BUG 修复</span></a></h3>
<ol>
<li>
<p>修复 laravel9 中代码生成器报错问题</p>
</li>
<li>
<p>修复 Laravel9 发布语言文件路径错误 (<a href="https://github.com/jqhph/dcat-admin/pull/1688" target="_blank" rel="noopener noreferrer">#1688 by @laradocs</a>)</p>
</li>
<li>
<p>修复 <code v-pre>tab</code> 选项卡重复加载后不选中错误 (<a href="https://github.com/jqhph/dcat-admin/pull/1689" target="_blank" rel="noopener noreferrer">#1689 by @iljalukin</a>)</p>
</li>
<li>
<p>修复代码生成器提交失败保存状态 (<a href="https://github.com/jqhph/dcat-admin/pull/1690" target="_blank" rel="noopener noreferrer">#1690 @by laradocs</a>)</p>
</li>
<li>
<p>修复 <code v-pre>HasMany</code>表单中使用 <code v-pre>map</code> 字段错误问题 (<a href="https://github.com/jqhph/dcat-admin/pull/1701" target="_blank" rel="noopener noreferrer">#1701 by @mojiajuzi</a>)</p>
</li>
<li>
<p>修复代码生成器生成 Laravel9 语言文件路径错误 (<a href="https://github.com/jqhph/dcat-admin/pull/1711" target="_blank" rel="noopener noreferrer">#1711 by @laradocs</a>)</p>
</li>
<li>
<p>修复上传文件 <code v-pre>options</code> 被覆盖错误 (<a href="https://github.com/jqhph/dcat-admin/pull/1747" target="_blank" rel="noopener noreferrer">#1747 by @laradocs</a>)</p>
</li>
<li>
<p>修复 Grid 中 <code v-pre>editable</code> 方法触发 <code v-pre>xss</code> 错误 (<a href="https://github.com/jqhph/dcat-admin/pull/1755" target="_blank" rel="noopener noreferrer">#1755 by @laradocs</a>)</p>
</li>
<li>
<p>修复 Form 中 <code v-pre>number</code> 调用 <code v-pre>disable</code> 方法对自增减按钮失效 (<a href="https://github.com/jqhph/dcat-admin/pull/1771" target="_blank" rel="noopener noreferrer">#1771 @by @laradocs</a>)</p>
</li>
<li>
<p>修复 Form 中使用 <code v-pre>layout</code> 布局后 <code v-pre>HasMany</code> 字段删除子字段后验证规则依然生效问题(<a href="https://github.com/jqhph/dcat-admin/pull/1781" target="_blank" rel="noopener noreferrer">#1781 @by laradocs</a>)</p>
</li>
<li>
<p>修复 PHP8.1 中触发 <code v-pre>ltrim</code> 和 <code v-pre>htmlentities</code> 方法异常 (<a href="https://github.com/jqhph/dcat-admin/pull/1783" target="_blank" rel="noopener noreferrer">#1783 by @laradocs</a>)</p>
</li>
<li>
<p>修复 Grid 使用<code v-pre>$grid-&gt;column('xxx.xxx')</code>无法导出关联模型字段值问题 (<a href="https://github.com/jqhph/dcat-admin/pull/1740" target="_blank" rel="noopener noreferrer">#1740 by @xyzzxy123</a>)</p>
</li>
<li>
<p>修复项目路径中含有<code v-pre>Admin</code>造成代码生成器无法正常解析命名空间的问题 (<a href="https://github.com/jqhph/dcat-admin/pull/1778" target="_blank" rel="noopener noreferrer">#1778 by @GMD170629</a>)</p>
</li>
<li>
<p>修复 <code v-pre>embeds</code> 字段无法上传文件问题 (<a href="https://github.com/jqhph/dcat-admin/pull/1770" target="_blank" rel="noopener noreferrer">#1770 by @pianzhou2021</a>)</p>
</li>
</ol>
<h2 id="v2-2-0-beta" tabindex="-1"><a class="header-anchor" href="#v2-2-0-beta"><span>v2.2.0-beta</span></a></h2>
<p>发布时间 2022/2/20</p>
<p>升级方法，逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.2.0-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-1" tabindex="-1"><a class="header-anchor" href="#新增功能-1"><span>新增功能</span></a></h3>
<p><strong>1.增加对Laravel9.x版本的支持</strong></p>
<p><strong>2.支持在<code v-pre>hasMany</code>以及<code v-pre>array</code>表单中使用<code v-pre>table</code>表单</strong></p>
<p>用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">array</span><span class="token punctuation">(</span><span class="token variable">$field</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">table</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'table_json'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'title'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.数据表格过滤器增加findInSet方法</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1639" target="_blank" rel="noopener noreferrer">#1639 @guanguans</a> sql: <code v-pre>... WHERE FIND_IN_SET(&quot;$input&quot;, $column)</code>，示例</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$filter</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$filter</span><span class="token operator">-></span><span class="token function">findInSet</span><span class="token punctuation">(</span><span class="token variable">$field</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.调整代码生成器选择默认目录逻辑</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1514" target="_blank" rel="noopener noreferrer">#1627 @Edwin</a> 新版本将会根据配置参数<code v-pre>admin.directory</code>设置的目录作为默认目录，默认为<code v-pre>Admin</code>。</p>
<h3 id="bug修复" tabindex="-1"><a class="header-anchor" href="#bug修复"><span>BUG修复</span></a></h3>
<ol>
<li>修复<code v-pre>table</code>表单不支持<code v-pre>help</code>方法问题 <a href="https://github.com/jqhph/dcat-admin/pull/1616" target="_blank" rel="noopener noreferrer">#1616 @jcbt</a></li>
<li>修复启用多应用后注册扩展路由会导致默认应用首页无法访问问题</li>
<li>修复无法隐藏弹窗表单重置按钮问题 <a href="https://github.com/jqhph/dcat-admin/pull/1631" target="_blank" rel="noopener noreferrer">#1631 @Sparkinzy</a></li>
<li>修复<code v-pre>autocomplete</code>当字段值为数字时js组件报错问题 <a href="https://github.com/jqhph/dcat-admin/pull/1661" target="_blank" rel="noopener noreferrer">#1661 @Sparkinzy</a></li>
<li>修复设置路由前缀为”/“时权限管理表单无法读取路由信息问题</li>
</ol>
<h2 id="v2-1-7-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-7-beta"><span>v2.1.7-beta</span></a></h2>
<p>发布时间 2021/12/25</p>
<p>升级方法，逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.7-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-2" tabindex="-1"><a class="header-anchor" href="#新增功能-2"><span>新增功能</span></a></h3>
<p><strong>1.增加<code v-pre>admin_redirect</code>函数</strong></p>
<p>跳转到指定<code v-pre>url</code>，此函数可用于代替<code v-pre>redirect</code>函数，支持<code v-pre>pjax</code>以及<code v-pre>ajax</code>请求</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 不需要添加admin前缀</span></span>
<span class="line"><span class="token keyword">return</span> <span class="token function">admin_redirect</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'auth/users'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 如果想要跳转到非admin前缀的链接，需要传递完整url链接</span></span>
<span class="line"><span class="token keyword">return</span> <span class="token function">admin_redirect</span><span class="token punctuation">(</span><span class="token function">url</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'users'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-1" tabindex="-1"><a class="header-anchor" href="#bug修复-1"><span>BUG修复</span></a></h3>
<ol>
<li>修复使用文件(file)上传表单删除文件时会报<code v-pre>destroyThumbnail</code>问题</li>
<li>修复当<code v-pre>hasMany</code>/<code v-pre>array</code>/<code v-pre>table</code>表单字段名与子表单字段名一样时无法删除行数据问题</li>
</ol>
<h2 id="v2-1-6-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-6-beta"><span>v2.1.6-beta</span></a></h2>
<p>发布时间 2021/12/12</p>
<p>升级方法，逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.6-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-3" tabindex="-1"><a class="header-anchor" href="#新增功能-3"><span>新增功能</span></a></h3>
<p><strong>1.增加<code v-pre>Form::autocomplete()</code>表单</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1514" target="_blank" rel="noopener noreferrer">#1514 @Edwin</a> 此表单可以在填写表单时进行对表单值进行搜索，并把结果展示在下拉列表中，用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">autocomplete</span><span class="token punctuation">(</span><span class="token variable">$column</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token variable">$label</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">options</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'foo'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'bar'</span><span class="token punctuation">,</span> <span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>效果如下<br>
<img src="https://cdn.learnku.com/uploads/images/202112/12/38389/ArVNSvChag.png!large" alt=""></p>
<p>也可以从远程API中获取数据</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// ajax 函数的第一个参数为 ajax url, 第二个参数为 valueField（可选）, 第三个参数为 groupField（可选）</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">autocomplete</span><span class="token punctuation">(</span><span class="token variable">$column</span><span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token variable">$label</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">ajax</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'/countries'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'name'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'region'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>远程API 服务端的请求参数为query，示例代码如下：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">CountryController</span> <span class="token keyword">extends</span> <span class="token class-name">AdminController</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">search</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$countries</span> <span class="token operator">=</span> <span class="token class-name static-context">Country</span><span class="token operator">::</span><span class="token function">when</span><span class="token punctuation">(</span><span class="token function">request</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'query'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$query</span><span class="token punctuation">,</span> <span class="token variable">$value</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token variable">$query</span><span class="token operator">-></span><span class="token function">where</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'name'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'like'</span><span class="token punctuation">,</span> <span class="token string double-quoted-string">"%<span class="token interpolation"><span class="token punctuation">{</span><span class="token variable">$value</span><span class="token punctuation">}</span></span>%"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token keyword">return</span> <span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">json</span><span class="token punctuation">(</span><span class="token variable">$countries</span><span class="token operator">-></span><span class="token function">toArray</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>更多用法参考文档<a href="https://learnku.com/docs/dcat-admin/2.x/use-of-fields/8107#autocomplete" target="_blank" rel="noopener noreferrer">数据表单 - 字段使用 - autocomplete</a></p>
<p><strong>2.图片/文件上传支持<code v-pre>arttribute</code>方法</strong><br>
<a href="https://github.com/jqhph/dcat-admin/pull/1510" target="_blank" rel="noopener noreferrer">#1510 @iwzh</a> 通过<code v-pre>attribute</code>方法可以给文件上传的隐藏域表单设置属性，用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token variable">$column</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">attribute</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'foo'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'bar'</span><span class="token punctuation">,</span> <span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>3.数据表格增加<code v-pre>between</code>表头过滤器</strong><br>
<a href="https://github.com/jqhph/dcat-admin/pull/1510" target="_blank" rel="noopener noreferrer">#1510 @iwzh</a> 用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'created_at'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Between</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">datetime</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.模型树增加<code v-pre>depthColumn</code>用于保存当前层级</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1510" target="_blank" rel="noopener noreferrer">#1549 @weiwait</a></p>
<p>用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">Category</span> <span class="token keyword">extends</span> <span class="token class-name">Model</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">use</span> <span class="token package">ModelTree</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 定义depthColumn属性后，将会在数据表保存当前行的层级</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$depthColumn</span> <span class="token operator">=</span> <span class="token string single-quoted-string">'depth'</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5.表单<code v-pre>Row</code>布局可独立设置宽度</strong><br>
<a href="https://github.com/jqhph/dcat-admin/pull/1530" target="_blank" rel="noopener noreferrer">#1530 @iwzh</a> 用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">row</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$row</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 给所有字段设置默认宽度</span></span>
<span class="line">    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">defaultWidth</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 每个字段独立设置宽度</span></span>
<span class="line">    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">width</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进" tabindex="-1"><a class="header-anchor" href="#功能改进"><span>功能改进</span></a></h3>
<p><strong>1.调整数据表格导出数据时rows方法回调函数接受的参数类型为Collection</strong><br>
<a href="https://github.com/jqhph/dcat-admin/pull/1584" target="_blank" rel="noopener noreferrer">#1584 @jourdon</a> 用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Illuminate<span class="token punctuation">\</span>Support<span class="token punctuation">\</span>Collection</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">export</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">rows</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Collection</span> <span class="token variable">$rows</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$rows</span> <span class="token keyword">as</span> <span class="token variable">$index</span> <span class="token operator">=></span> <span class="token operator">&amp;</span><span class="token variable">$row</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">       <span class="token comment">// $row 的格式为模型</span></span>
<span class="line">       <span class="token function">dd</span><span class="token punctuation">(</span><span class="token variable">$row</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$rows</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-2" tabindex="-1"><a class="header-anchor" href="#bug修复-2"><span>BUG修复</span></a></h3>
<ol>
<li>修复使用OSS上传图片缩略图报错问题 <a href="https://github.com/jqhph/dcat-admin/pull/1499" target="_blank" rel="noopener noreferrer">#1499 @jorry2008</a></li>
<li>修复数据表格筛选默认项不能设置为<code v-pre>0</code>问题 <a href="https://github.com/jqhph/dcat-admin/pull/1506" target="_blank" rel="noopener noreferrer">#1506 @liushoukun</a></li>
<li>修复一对一关联关系表单验证规则异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/1516" target="_blank" rel="noopener noreferrer">#1516</a></li>
<li>修复表单文件上传时，若已添加过文件则无法继续拖拽上传问题 <a href="https://github.com/jqhph/dcat-admin/pull/1541" target="_blank" rel="noopener noreferrer">#1541 @hmilyfyj</a></li>
<li>修复分页器在<code v-pre>LazyRenderable</code>下切换时导致样式丢失的问题 <a href="https://github.com/jqhph/dcat-admin/pull/1539" target="_blank" rel="noopener noreferrer">#1539 @jyiL</a></li>
<li>修复数据表格使用MongoDB时分页<code v-pre>perPage</code>数据类型错误问题 <a href="https://github.com/jqhph/dcat-admin/pull/1555" target="_blank" rel="noopener noreferrer">#1555 @SmallRuralDog</a></li>
<li>修复页面使用<code v-pre>pjax</code>渲染后<code v-pre>pjax</code>无法再次初始化<code v-pre>a</code>标签问题 <a href="https://github.com/jqhph/dcat-admin/pull/1576" target="_blank" rel="noopener noreferrer">#1576 @xyzzxy123</a></li>
<li>修复数据表格<code v-pre>Column::switch()</code>方法<code v-pre>refresh</code>参数无效问题 <a href="https://github.com/jqhph/dcat-admin/pull/1595" target="_blank" rel="noopener noreferrer">#1595 @wxfjamdc</a></li>
<li>修复多图片上传上传多个图片会导致旧图片缩略图被删除问题 <a href="https://github.com/jqhph/dcat-admin/issues/1556" target="_blank" rel="noopener noreferrer">#1556</a></li>
</ol>
<h2 id="v2-1-5-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-5-beta"><span>v2.1.5-beta</span></a></h2>
<p>发布时间 2021/9/17</p>
<p>升级方法，逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.5-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-3" tabindex="-1"><a class="header-anchor" href="#bug修复-3"><span>BUG修复</span></a></h3>
<ul>
<li>修复<code v-pre>v2.1.4</code>版本更新后不兼容<code v-pre>php v7.3</code>以下版本问题</li>
</ul>
<h2 id="v2-1-4-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-4-beta"><span>v2.1.4-beta</span></a></h2>
<p>发布时间 2021/9/16</p>
<p>升级方法，逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.4-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-4" tabindex="-1"><a class="header-anchor" href="#bug修复-4"><span>BUG修复</span></a></h3>
<ol>
<li>修复管理员列表点击查看权限弹窗展示为空问题</li>
<li>修复数据表格关联关系表字段<code v-pre>非equal</code>查询均不生效问题</li>
<li>修复数据表格<code v-pre>column</code>使用<code v-pre>if</code>方法后无法在<code v-pre>displayer</code>中取得原始字段值问题</li>
</ol>
<h2 id="v2-1-3-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-3-beta"><span>v2.1.3-beta</span></a></h2>
<p>发布时间 2021/9/14</p>
<p>升级方法，逐步执行以下命令，最后清除<strong>浏览器缓存</strong></p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.3-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-1" tabindex="-1"><a class="header-anchor" href="#功能改进-1"><span>功能改进</span></a></h3>
<p><strong>1.重构数据表格行内编辑功能</strong></p>
<p>当前版本重构了<code v-pre>editable</code>、<code v-pre>checkbox</code>和<code v-pre>radio</code>等三种行内编辑表单的<code v-pre>UI</code>样式，改为在弹窗中展示表单。并且增加了新的行内编辑表单<code v-pre>textarea</code>，效果如下：</p>
<p><img src="https://cdn.learnku.com/uploads/images/202109/14/38389/mX4Za4nj1y.png!large" alt=""><br>
<img src="https://cdn.learnku.com/uploads/images/202109/14/38389/9A2GdY3nSx.png!large" alt=""><br>
<img src="https://cdn.learnku.com/uploads/images/202109/14/38389/6Bo4phkB3f.png!large" alt=""><br>
<img src="https://cdn.learnku.com/uploads/images/202109/14/38389/wViO5EoPBg.png!large" alt=""></p>
<p><strong>2.配置文件增加<code v-pre>favicon</code>参数</strong></p>
<p>从当前版本开始可以在<code v-pre>config/admin.php</code>中配置<code v-pre>favicon</code>链接，参数名为<code v-pre>favicon</code></p>
<p><strong>3.数据表单提交时支持展示被抛出异常的<code v-pre>message</code></strong></p>
<p>从当前版本开始，假如提交表单时抛出异常如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">submitted</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name class-name-fully-qualified"><span class="token punctuation">\</span>Exception</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'禁止访问'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>那么将可以在页面中看到如下提示</p>
<p><img src="https://cdn.learnku.com/uploads/images/202109/14/38389/S0KtwNRYGK.png!large" alt=""></p>
<p><strong>5.优化<code v-pre>array</code>、<code v-pre>table</code>表单在工具表单中的使用</strong></p>
<p>在旧版本<code v-pre>Widgtet/Form</code>中如果使用了<code v-pre>array</code>、<code v-pre>table</code>表单，并且在<code v-pre>array</code>、<code v-pre>table</code>表单中使用了文件上传表单时，需要自定义文件上传地址才能正常上传，所以此次版本对这个功能做了优化，更新版本之后将不需要再自定义上传地址</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$this</span><span class="token operator">-></span><span class="token function">array</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 无需自定义上传地址</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">image</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.增加数据表单<code v-pre>html</code>对<code v-pre>addElementClass</code>方法的支持</strong></p>
<p>在旧版本中，<code v-pre>addElementClass</code>设置的<code v-pre>class</code>无法对<code v-pre>html</code>方法生效，所以新版中对此做了改进</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">html</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">addElementClass</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'class1'</span><span class="token punctuation">,</span> <span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>5.数据表单图片上传表单访问缩略图时不检查图片是否存在</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1455" target="_blank" rel="noopener noreferrer">@zhaiyuxin103</a></p>
<h3 id="bug修复-5" tabindex="-1"><a class="header-anchor" href="#bug修复-5"><span>BUG修复</span></a></h3>
<ol>
<li>修复数据表单使用闭包验证规则时无法正确合并问题 <a href="https://github.com/jqhph/dcat-admin/pull/1429" target="_blank" rel="noopener noreferrer">#1429 @Edwin</a></li>
<li>修复文件上传启用<code v-pre>sequenceName</code>方法后生成的文件名带有重复后缀问题</li>
<li>修复文件上传表单上传一对一字段设置<code v-pre>required</code>验证规则后无法上传文件问题</li>
<li>修复某些操作下出现空白筛选边栏的问题 <a href="https://github.com/jqhph/dcat-admin/pull/1445" target="_blank" rel="noopener noreferrer">#1445 @Abbotton</a></li>
<li>修复<code v-pre>selectTable</code>、<code v-pre>multipleSelectTable</code>等字段的<code v-pre>model</code>方法指定第二个参数无效问题 <a href="https://github.com/jqhph/dcat-admin/pull/1460" target="_blank" rel="noopener noreferrer">#1460 @hhniao</a></li>
<li>修复无法翻译图片上传表单<code v-pre>dimensions</code>验证失败提示文案问题</li>
<li>修复当在<code v-pre>array</code>、<code v-pre>table</code>以及<code v-pre>hasMany</code>表单中使用图片上传表单，并且设置<code v-pre>dimensions</code>验证规则后无法提交问题</li>
<li>修复多图上传只能预览第一个图片问题</li>
<li>修复表单动态展示如果字段值带小数点时不生效问题</li>
</ol>
<h2 id="v2-1-2-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-2-beta"><span>v2.1.2-beta</span></a></h2>
<p><img src="https://cdn.learnku.com/uploads/images/202109/14/38389/mX4Za4nj1y.png!large" alt=""><br>
<img src="https://cdn.learnku.com/uploads/images/202109/14/38389/6Bo4phkB3f.png!large" alt=""><br>
<img src="https://cdn.learnku.com/uploads/images/202109/14/38389/wViO5EoPBg.png!large" alt=""><br>
<img src="https://cdn.learnku.com/uploads/images/202109/14/38389/S0KtwNRYGK.png!large" alt=""><br>
发布时间 2021/8/1</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.2-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-2" tabindex="-1"><a class="header-anchor" href="#功能改进-2"><span>功能改进</span></a></h3>
<p><strong>1.增加 Grid\Model::apply() 方法</strong></p>
<p>此方法可以应用数据表格的快捷搜索和筛选过滤的查询条件，用法示例如下</p>
<p>在旧版本中，使用快捷搜索和筛选过滤的查询条件非常的麻烦</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">header</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$collection</span><span class="token punctuation">)</span> <span class="token keyword">use</span> <span class="token punctuation">(</span><span class="token variable">$grid</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$query</span> <span class="token operator">=</span> <span class="token class-name static-context">Model</span><span class="token operator">::</span><span class="token function">query</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 拿到表格筛选 where 条件数组进行遍历</span></span>
<span class="line">    <span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">model</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">getQueries</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">unique</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">each</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$value</span><span class="token punctuation">)</span> <span class="token keyword">use</span> <span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token variable">$query</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">in_array</span><span class="token punctuation">(</span><span class="token variable">$value</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'method'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'paginate'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'get'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'orderBy'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'orderByDesc'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token constant boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token keyword">return</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">        <span class="token variable">$query</span> <span class="token operator">=</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token variable">$query</span><span class="token punctuation">,</span> <span class="token variable">$value</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'method'</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token variable">$value</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'arguments'</span><span class="token punctuation">]</span> <span class="token operator">??</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 查出统计数据</span></span>
<span class="line">    <span class="token variable">$data</span> <span class="token operator">=</span> <span class="token variable">$query</span><span class="token operator">-></span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 自定义组件</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Card</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>从当前版本开始可以使用<code v-pre>apply</code>方法简化上面的代码</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">header</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$collection</span><span class="token punctuation">)</span> <span class="token keyword">use</span> <span class="token punctuation">(</span><span class="token variable">$grid</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$query</span> <span class="token operator">=</span> <span class="token class-name static-context">Model</span><span class="token operator">::</span><span class="token function">query</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 拿到表格筛选 where 条件数组进行遍历</span></span>
<span class="line">    <span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">model</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">apply</span><span class="token punctuation">(</span><span class="token variable">$query</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 查出统计数据</span></span>
<span class="line">    <span class="token variable">$data</span> <span class="token operator">=</span> <span class="token variable">$query</span><span class="token operator">-></span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 自定义组件</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Card</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-6" tabindex="-1"><a class="header-anchor" href="#bug修复-6"><span>BUG修复</span></a></h3>
<ol>
<li>修复数据表格无法禁用批量删除按钮问题</li>
<li>修复高德地图表单有坐标时没有缩放问题 <a href="https://github.com/jqhph/dcat-admin/pull/1377" target="_blank" rel="noopener noreferrer">#1377 @gzxy-0102</a></li>
<li>修复文件上传表单下载按钮不显示问题 <a href="https://github.com/jqhph/dcat-admin/issues/1405" target="_blank" rel="noopener noreferrer">#1405</a></li>
<li>修复数据表格使用了<code v-pre>simplePaginate</code>后数据筛选参数不生效问题 <a href="https://github.com/jqhph/dcat-admin/issues/1405" target="_blank" rel="noopener noreferrer">#1405</a></li>
</ol>
<h2 id="v2-1-1-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-1-beta"><span>v2.1.1-beta</span></a></h2>
<p>发布时间 2021/7/12</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.1-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-4" tabindex="-1"><a class="header-anchor" href="#新增功能-4"><span>新增功能</span></a></h3>
<p><strong>1.增加模型树expand方法控制是否展开所有子节点数据</strong></p>
<p>默认展开所有子节点数据</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 展开子节点数据</span></span>
<span class="line"><span class="token variable">$tree</span><span class="token operator">-></span><span class="token function">expand</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 收起所有子节点数据</span></span>
<span class="line"><span class="token variable">$tree</span><span class="token operator">-></span><span class="token function">expand</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>2.增加文件上传表单下载功能</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">downloadable</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>3.增加高德地图表单</strong></p>
<p>在配置文件<code v-pre>config/admin.php</code>中设置 <a href="https://github.com/jqhph/dcat-admin/pull/1331" target="_blank" rel="noopener noreferrer">#1331 @gaizhixin</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">    <span class="token string single-quoted-string">'map'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'provider'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'amap'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token string single-quoted-string">'keys'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token comment">// 配置高德地图的key</span></span>
<span class="line">            <span class="token string single-quoted-string">'amap'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'key'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.新增addElementClass方法用于给表单字段设置自定义class</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 如果不希望添加前缀，则第二个参数设置为false</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">addElementClass</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'class1'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'class2'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5.增加表格批量操作设置下拉菜单分割线功能</strong></p>
<p>支持以下两种方式</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 方式1</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">batchActions</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$batch</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$batch</span><span class="token operator">-></span><span class="token function">add</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 显示分割线</span></span>
<span class="line">    <span class="token variable">$batch</span><span class="token operator">-></span><span class="token function">divider</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 方式2</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Tools<span class="token punctuation">\</span>ActionDivider</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">batchActions</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">    <span class="token keyword">new</span> <span class="token class-name">Action1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line">    <span class="token keyword">new</span> <span class="token class-name">ActionDivider</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-3" tabindex="-1"><a class="header-anchor" href="#功能改进-3"><span>功能改进</span></a></h3>
<p><strong>1.table表单支持自定义view</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$this</span><span class="token operator">-></span><span class="token function">table</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">setView</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>2.优化菜单收缩后的操作体验以及UI</strong></p>
<p>当菜单收缩后，光标移动上去后自动展开如果点击了菜单，跳转后会自动收缩回去；并且修复了<code v-pre>mini-logo</code>显示异常的问题</p>
<p><strong>3.数据表格行操作列当没有任何操作按钮时不再显示空的下拉菜单</strong></p>
<p>数据表格行操作列当没有任何操作按钮时不再显示空的下拉菜单 <a href="https://github.com/jqhph/dcat-admin/pull/1331" target="_blank" rel="noopener noreferrer">#1327 @jiangyuntao</a></p>
<p><strong>4.优化图片上传表单图片的显示效果</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1366" target="_blank" rel="noopener noreferrer">#1366 @ShermanTsang</a></p>
<h3 id="bug修复-7" tabindex="-1"><a class="header-anchor" href="#bug修复-7"><span>BUG修复</span></a></h3>
<ol>
<li>修复树形表格(<code v-pre>tree</code>)展开子节点时如果无数据<code v-pre>Grid::__toString()</code>会报错问题</li>
<li>修复启用数据表格异步渲染功能后减少筛选条件无效问题</li>
<li>修复表格异步渲染筛选项数量显示异常问题</li>
<li>修复设置表单字段<code v-pre>class</code>会覆盖默认<code v-pre>class</code>问题</li>
<li>修复关闭<code v-pre>debug</code>模式后访问无权限页面会显示异常报文问题</li>
<li>修复配置文件自定义批量删除按钮后 <code v-pre>Grid::disableBatchDelete</code> 失效问题</li>
<li>修复菜单缩进后三级菜单无法隐藏问题</li>
<li>修复当设置为无路由前缀时，内置的权限系统点击<code v-pre>新增权限</code>报错的问题</li>
<li>修复当禁用内置权限系统时没有禁用掉权限中间件无效问题</li>
<li>修复<code v-pre>select</code>以及<code v-pre>selectTable</code>的<code v-pre>model</code>传递了第二个参数为非<code v-pre>id</code>时无法显示编辑数据的问题</li>
<li>修复部分表单设置大小样式未生效的问题 <a href="https://github.com/jqhph/dcat-admin/pull/1361" target="_blank" rel="noopener noreferrer">#1361 @Abbotton</a></li>
<li>修复表格排序功能无法兼容<code v-pre>Grid\Model::latest</code>以及<code v-pre>oldest</code>方法问题</li>
</ol>
<h2 id="v2-1-0-beta" tabindex="-1"><a class="header-anchor" href="#v2-1-0-beta"><span>v2.1.0-beta</span></a></h2>
<p>发布时间 2021/5/23</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.1.0-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-5" tabindex="-1"><a class="header-anchor" href="#新增功能-5"><span>新增功能</span></a></h3>
<p><strong>1.增加表格异步渲染功能</strong></p>
<p>当页面的表格展示的数据特别多（列多行多），并且加载的组件也较多时，可能会出现卡顿的现象，此时可以使用表格异步渲染功能，可以有效地减轻页面卡顿的情况：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 启用表格异步渲染功能</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">async</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>需要注意的是，如果页面没有出现明显的卡顿现象，则无需启用此功能，并且如果页面中存在多个数据表格，那么也无法使用此功能！详细用法参考<a href="https://learnku.com/docs/dcat-admin/2.x/asynchronous-rendering/11051" target="_blank" rel="noopener noreferrer">异步渲染《Dcat Admin 中文文档》</a></p>
<h3 id="功能改进-4" tabindex="-1"><a class="header-anchor" href="#功能改进-4"><span>功能改进</span></a></h3>
<p><strong>1.支持<code v-pre>Laravel Octane 1.x</code>版本</strong></p>
<p>此次版本适配了<code v-pre>Laravel Octane 1.x</code>版本的相关变动，具体用法参考<a href="https://learnku.com/docs/dcat-admin/2.x/beta-version-update-log/laravel-octane.md" target="_blank" rel="noopener noreferrer">Laravel Octane</a>。</p>
<p><strong>2.调用<code v-pre>expand(false)</code>可以禁止自动弹出过滤器侧栏</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 禁止自动弹出过滤器侧边栏</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$filter</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$filter</span><span class="token operator">-></span><span class="token function">expand</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.升级<code v-pre>tinymce</code>至<code v-pre>v5.8.0</code>版本</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1263" target="_blank" rel="noopener noreferrer">@yiming0</a></p>
<p><strong>4.权限以及角色页面绑定菜单后自动清除菜单缓存</strong></p>
<h3 id="bug修复-8" tabindex="-1"><a class="header-anchor" href="#bug修复-8"><span>BUG修复</span></a></h3>
<p>1. 修复<code v-pre>withConstraints</code>方法对详情页<code v-pre>url</code>无效问题 <a href="https://github.com/jqhph/dcat-admin/issues/1232" target="_blank" rel="noopener noreferrer">#1232</a><br>
2. 修复多图/文件上传表单删除图片时表单值会转化成关联数组问题<br>
3. 修复百度地图组件在启用<code v-pre>https</code>后无法使用问题 <a href="https://github.com/jqhph/dcat-admin/issues/1162" target="_blank" rel="noopener noreferrer">#1162</a></p>
<h2 id="v2-0-24-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-24-beta"><span>v2.0.24-beta</span></a></h2>
<p>发布时间 2021/4/30</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.24-beta"</span></span>
<span class="line">php artisan admin:update <span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-6" tabindex="-1"><a class="header-anchor" href="#新增功能-6"><span>新增功能</span></a></h3>
<p><strong>1.增加创建或编辑角色以及权限时可直接绑定菜单功能</strong></p>
<p>在角色和权限的创建以及编辑页面可以直接绑定菜单，此功能默认开启，可以通过配置参数<code v-pre>admin.menu.role_bind_menu</code>以及<code v-pre>admin.menu.permission_bind_menu</code>进行关闭，效果如下</p>
<p><img src="https://cdn.learnku.com/uploads/images/202104/30/38389/OUgvZVSA5l.jpg!large" alt=""></p>
<p><strong>2.新增<code v-pre>Form\Tree::treeStatus()</code>方法，允许单独选择父节点</strong></p>
<p>用法</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">tree</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'xxx'</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">treeState</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span> <span class="token comment"># 允许单独选择父节点</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">setTitleColumn</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'title'</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">nodes</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>效果<br>
<img src="https://cdn.learnku.com/uploads/images/202104/30/38389/oChwzky2BT.gif!large" alt=""></p>
<h3 id="bug修复-9" tabindex="-1"><a class="header-anchor" href="#bug修复-9"><span>BUG修复</span></a></h3>
<ol>
<li>修复多应用情况下无法使用域名区分应用问题</li>
<li>修复<code v-pre>Admin::pjax()</code>方法未声明为<code v-pre>static</code>问题</li>
<li>修复<code v-pre>grid filter checkbox</code>只能选中多个选项后只有单个选项生效问题 <a href="https://github.com/jqhph/dcat-admin/pull/1174" target="_blank" rel="noopener noreferrer">@outer199</a></li>
<li>修复菜单默认图标设置无效问题</li>
<li>修复<code v-pre>php7.4</code>或以上版本中使用<code v-pre>embeds</code>表单时报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/1204" target="_blank" rel="noopener noreferrer">#1204</a></li>
<li>修复分步表单下使用<code v-pre>$form-&gt;list(...)-&gt;limit(...);</code>参数校验不通过后刷新页面报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/1206" target="_blank" rel="noopener noreferrer">#1206</a></li>
<li>修复禁用<code v-pre>pjax</code>后编辑和创建完成后无法进行跳转问题 <a href="https://github.com/jqhph/dcat-admin/issues/1208" target="_blank" rel="noopener noreferrer">#1208</a></li>
<li>修复使用固定列功能时列表会多出一列<code v-pre>ActionsClass</code>问题</li>
</ol>
<h2 id="v2-0-23-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-23-beta"><span>v2.0.23-beta</span></a></h2>
<p>发布时间 2021/4/18</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.23-beta"</span></span>
<span class="line"><span class="token comment"># 不会覆盖翻译文件 menu.php 以及 global.php</span></span>
<span class="line">php artisan admin:update</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-7" tabindex="-1"><a class="header-anchor" href="#新增功能-7"><span>新增功能</span></a></h3>
<p><strong>1.增加对<code v-pre>Laravel Octane</code>的支持</strong></p>
<p><a href="https://github.com/laravel/octane" target="_blank" rel="noopener noreferrer">Laravel Octane</a> 是一个基于 <code v-pre>Swoole/RoadRunner</code> 驱动的可以提升 <code v-pre>Laravel</code> 框架性能的项目，安装后可以大幅提升<code v-pre>Laravel</code>项目的性能，<code v-pre>Dcat Admin</code>也兼容了<code v-pre>Laravel Octane</code>环境，只需在配置文件<code v-pre>config/octane.php</code>中加入如下配置即可：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"></span>
<span class="line">    <span class="token string single-quoted-string">'listeners'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token operator">...</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token class-name static-context">RequestReceived</span><span class="token operator">::</span><span class="token keyword">class</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token operator">...</span><span class="token class-name static-context">Octane</span><span class="token operator">::</span><span class="token function">prepareApplicationForNextOperation</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token operator">...</span><span class="token class-name static-context">Octane</span><span class="token operator">::</span><span class="token function">prepareApplicationForNextRequest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">            <span class="token comment">// 开启对 Dcat Admin 的支持</span></span>
<span class="line">            <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Octane<span class="token punctuation">\</span>Listeners<span class="token punctuation">\</span>FlushAdminState</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span>    </span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p><a href="https://github.com/laravel/octane" target="_blank" rel="noopener noreferrer">Laravel Octane</a>目前仍处于<code v-pre>beta</code>版本阶段，关于<a href="https://github.com/laravel/octane" target="_blank" rel="noopener noreferrer">Laravel Octane</a>的安装与更多介绍请前往文档 <a href="https://github.com/laravel/octane" target="_blank" rel="noopener noreferrer">github.com/laravel/octane</a> 查看。</p>
</blockquote>
<p><strong>2.增加表格简化分页（<code v-pre>simplePaginate</code>）功能</strong></p>
<p>启用 <code v-pre>simplePaginate</code> 功能后会使用<code v-pre>Laravel</code>的<a href="https://learnku.com/docs/laravel/8.x/pagination#simple-pagination" target="_blank" rel="noopener noreferrer">simplePaginate</a>功能进行分页，当数据量较大时可以大幅提升页面的响应速度，但需要注意的是，使用此功能后将不会查询数据表的<strong>总行数</strong>。</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 启用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">simplePaginate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 禁用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">simplePaginate</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-5" tabindex="-1"><a class="header-anchor" href="#功能改进-5"><span>功能改进</span></a></h3>
<p><strong>1.重构翻译功能</strong></p>
<p>在过去版本中，当使用<a href="https://learnku.com/docs/dcat-admin/2.x/beta-version-update-log/lazy.md" target="_blank" rel="noopener noreferrer">异步表单</a>以及<a href="https://learnku.com/docs/dcat-admin/2.x/beta-version-update-log/lazy.md" target="_blank" rel="noopener noreferrer">异步表格</a>功能时无法自动对字段名称进行翻译，从当前版本开始可以通过<code v-pre>translation</code>属性指定翻译文件的路径进行自动翻译，用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">App<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Forms</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Traits<span class="token punctuation">\</span>LazyWidget</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Widgets<span class="token punctuation">\</span>Form</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Contracts<span class="token punctuation">\</span>LazyRenderable</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">MyForm</span> <span class="token keyword">extends</span> <span class="token class-name">Form</span> <span class="token keyword">implements</span> <span class="token class-name">LazyRenderable</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">use</span> <span class="token package">LazyWidget</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 指定翻译文件名称</span>
<span class="line">     * </span>
<span class="line">     * <span class="token keyword">@var</span> <span class="token class-name"><span class="token keyword">string</span></span> </span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$translation</span> <span class="token operator">=</span> <span class="token string single-quoted-string">'my-form'</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">form</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'field1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'field2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>语言包<code v-pre>resources/lang/{locale}/my-form.php</code>内容如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'fields'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'field1'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'字段1'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token string single-quoted-string">'field2'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'字段2'</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>并且在控制器中也可以指定当前翻译文件的路径</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Http<span class="token punctuation">\</span>Controllers<span class="token punctuation">\</span>AdminController</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">UserController</span> <span class="token keyword">extends</span> <span class="token class-name">AdminController</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 指定翻译文件名称</span>
<span class="line">     * </span>
<span class="line">     * <span class="token keyword">@var</span> <span class="token class-name"><span class="token keyword">string</span></span> </span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$translation</span> <span class="token operator">=</span> <span class="token string single-quoted-string">'user1'</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>当然也可以通过<code v-pre>Admin::translation()</code>方法指定</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Admin</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">translation</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>2.增加表格相关配置参数</strong></p>
<p>增加数个表格相关的配置文件参数<code v-pre>admin.grid.*</code>:</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">    <span class="token string single-quoted-string">'grid'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 表格行操作类</span></span>
<span class="line">        <span class="token string single-quoted-string">'grid_action_class'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Displayers<span class="token punctuation">\</span>DropdownActions</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 表格批量操作类</span></span>
<span class="line">        <span class="token string single-quoted-string">'batch_action_class'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Tools<span class="token punctuation">\</span>BatchActions</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 表格分页类</span></span>
<span class="line">        <span class="token string single-quoted-string">'paginator_class'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Tools<span class="token punctuation">\</span>Paginator</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 表格行默认的几个操作类配置</span></span>
<span class="line">        <span class="token string single-quoted-string">'actions'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'view'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Actions<span class="token punctuation">\</span>Show</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'edit'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Actions<span class="token punctuation">\</span>Edit</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'quick_edit'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Actions<span class="token punctuation">\</span>QuickEdit</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'delete'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Actions<span class="token punctuation">\</span>Delete</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'batch_delete'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>Tools<span class="token punctuation">\</span>BatchDelete</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.移除禁用表格分页后显示表格页脚信息</strong></p>
<p>从当前版本开始，如果禁用了表格的分页功能，将不会再显示表格的页脚信息。</p>
<p><strong>4.优化 <code v-pre>Filter::panel()</code> 布局间距</strong></p>
<p><strong>5.优化文件发布功能，发布语言包文件时将不再覆盖<code v-pre>menu.php</code>以及<code v-pre>global.php</code>文件</strong></p>
<p>从当前版本开始，当使用<code v-pre>admin:update</code>以及<code v-pre>admin:publish --force</code>命令文件时，将不再覆盖<code v-pre>menu.php</code>以及<code v-pre>global.php</code>文件。</p>
<p><strong>6.更新<code v-pre>Tinymce</code>版本至<code v-pre>5.6.2</code></strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/1154" target="_blank" rel="noopener noreferrer">@wk1025</a></p>
<h3 id="bug修复-10" tabindex="-1"><a class="header-anchor" href="#bug修复-10"><span>BUG修复</span></a></h3>
<ol>
<li>修复数据表格中字段类型为<code v-pre>Object</code>时报错问题 <a href="https://github.com/jqhph/dcat-admin/pull/1154" target="_blank" rel="noopener noreferrer">@xiaohuilam</a></li>
<li>修复文件上传失败仍然提示上传成功问题</li>
<li>修复权限判断中间件匹配时没有使用传入的<code v-pre>$request</code>对象问题 <a href="https://github.com/jqhph/dcat-admin/pull/1157" target="_blank" rel="noopener noreferrer">@asmodai1985</a></li>
<li>修复表单<code v-pre>rules</code>方法第二个参数设置<code v-pre>message</code>无效问题</li>
<li>修复<code v-pre>Helper::array()</code>会把<code v-pre>0</code>转为空数组问题</li>
<li>修复行选择器无法选中树形表格子级行问题</li>
<li>修复<code v-pre>KeyValue::setValueLabel()</code>方法无效问题</li>
<li>修复<code v-pre>hasmany</code>以及<code v-pre>table</code>表单删除选项时会重置表单问题</li>
<li>修复表格行操作编辑按钮文本显示错误问题 <a href="https://github.com/jqhph/dcat-admin/pull/1174" target="_blank" rel="noopener noreferrer">@GemaDynamic</a></li>
<li>修复树形表格子级行无法正常使用表单弹窗问题 <a href="https://github.com/jqhph/dcat-admin/issues/1174" target="_blank" rel="noopener noreferrer">#813</a></li>
</ol>
<h2 id="v2-0-22-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-22-beta"><span>v2.0.22-beta</span></a></h2>
<p>发布时间 2021/4/1</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.22-beta"</span></span>
<span class="line">php artisan admin:update</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-11" tabindex="-1"><a class="header-anchor" href="#bug修复-11"><span>BUG修复</span></a></h3>
<ol>
<li>修复部分功能缺失<code v-pre>CSRF_TOKEN</code>报错问题</li>
<li>修复菜单自动适应高度功能报错问题</li>
</ol>
<h2 id="v2-0-21-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-21-beta"><span>v2.0.21-beta</span></a></h2>
<p>发布时间 2021/3/30</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.21-beta"</span></span>
<span class="line">php artisan admin:update</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="新增功能-8" tabindex="-1"><a class="header-anchor" href="#新增功能-8"><span>新增功能</span></a></h3>
<p><strong>1.增加表格列选择器<code v-pre>ColumnSelector</code>支持持久化存储功能</strong></p>
<p>在配置文件<code v-pre>config/admin.php</code>可以配置存储列选择器状态的方式，支持的存储方式如下</p>
<ul>
<li><code v-pre>Dcat\Admin\Grid\ColumnSelector\SessionStore</code> 列选择器状态数据保存在<code v-pre>session</code>中，仅在登陆中有效</li>
<li><code v-pre>Dcat\Admin\Grid\ColumnSelector\CacheStore</code> 列选择器状态数据保存在<a href="https://learnku.com/docs/laravel/8.x/cache#driver-prerequisites" target="_blank" rel="noopener noreferrer">Laravel Cache</a>缓存系统中，最长可保存<code v-pre>300</code>天，并可以通过<code v-pre>admin.grid.column_selector.store_params.driver</code>可以配置缓存驱动，默认为<code v-pre>file</code></li>
</ul>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">    <span class="token string single-quoted-string">'grid'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'column_selector'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'store'</span> <span class="token operator">=></span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid<span class="token punctuation">\</span>ColumnSelector<span class="token punctuation">\</span>SessionStore</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'store_params'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">                <span class="token string single-quoted-string">'driver'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'file'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>2.增加表格条件判断(<code v-pre>if</code>)的终结方法(<code v-pre>end</code>)</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'status'</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">if</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span> <span class="token comment">// 条件1</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">display</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">display</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">-></span><span class="token function">if</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span> <span class="token comment">// 条件2</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">display</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">display</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">-></span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 终结前面的条件判断</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">display</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 所有条件都能生效</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.增加表格行选择器默认选中(<code v-pre>check</code>)以及禁止更改选中状态(<code v-pre>disable</code>)功能</strong></p>
<p>通过<code v-pre>check</code>方法可以设置默认选中的行，此方法接受一个<code v-pre>array</code>类型或<code v-pre>匿名函数</code>参数</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 设置默认选中第 1/3/5 行</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">check</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 传递闭包</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">check</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 设置默认选中第 1/3/5 行</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token function">in_array</span><span class="token punctuation">(</span><span class="token variable">$this</span><span class="token operator">-></span><span class="token property">_index</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 在闭包中使用当前行其他字段</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">check</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 设置默认选中 id > 10 的行</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">id</span> <span class="token operator">></span> <span class="token number">10</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>通过<code v-pre>disable</code>方法可以设置禁止更改选中状态的行，此方法接受一个<code v-pre>array</code>类型或<code v-pre>匿名函数</code>参数</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 禁止第 1/3/5 行更改选中状态</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">disable</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 传递闭包</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">disable</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 禁止第 1/3/5 行更改选中状态</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token function">in_array</span><span class="token punctuation">(</span><span class="token variable">$this</span><span class="token operator">-></span><span class="token property">_index</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 在闭包中使用当前行其他字段</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">disable</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 禁止 id > 10 的行更改选中状态</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">id</span> <span class="token operator">></span> <span class="token number">10</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// disable 可以和 check 方法一起使用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">rowSelector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">check</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">disable</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.增加<code v-pre>KeyValue</code>表单自定义标题翻译功能</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">keyValue</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">setKeyLabel</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'键名'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">setValueLabel</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'键值'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>5.增加<code v-pre>Grid::scrollbarX</code>显示表格横向滚动条方法</strong></p>
<p>显示表格横向滚动条，默认不显示</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 启用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">scrollbarX</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 禁用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">scrollbarX</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.增加<code v-pre>admin:update</code>命令</strong><br>
从当前版本开始，升级后可以直接运行 <code v-pre>admin:update</code>，相当于运行</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan admin<span class="token punctuation">:</span>publish <span class="token operator">--</span>assets <span class="token operator">--</span>migrations <span class="token operator">--</span>lang <span class="token operator">--</span>force</span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-6" tabindex="-1"><a class="header-anchor" href="#功能改进-6"><span>功能改进</span></a></h3>
<p><strong>1.表单显示编辑数据时兼容驼峰风格的关联关系名称</strong></p>
<p>在旧版本中，如果需要编辑模型关联关系字段，且模型的关联关系名称为驼峰风格时，需要把名称更改为下划线风格才能正常显示，这对开发者非常不友好。从当前版本开始，可以直接使用驼峰风格的关联关系名称，不需要做任何特殊处理</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">return</span> <span class="token class-name static-context">Form</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token class-name static-context">User</span><span class="token operator">::</span><span class="token function">with</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'myProfile'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Form</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 直接使用驼峰风格命名，不需做其他处理</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'myProfile.full_name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>2.调整工具表单数据设置逻辑，可在<code v-pre>form</code>方法中获取<code v-pre>default</code>方法数据</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Widgets<span class="token punctuation">\</span>Form</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">Setting</span> <span class="token keyword">extends</span> <span class="token class-name">Form</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">form</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token comment">// 获取 default 方法设置的数据</span></span>
<span class="line">        <span class="token variable">$id</span> <span class="token operator">=</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token property">id</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token variable">$name</span> <span class="token operator">=</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token property">name</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">default</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'id'</span> <span class="token operator">=></span> <span class="token number">1</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'name'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'abc'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token operator">...</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.<code v-pre>hasMany</code>以及<code v-pre>array</code>表单支持整体使用<code v-pre>rules</code>验证规则校验</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">hasMany</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">rules</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'size:2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>4.调整<code v-pre>selectTable</code>默认占位符为<code v-pre>选择 ...</code></strong></p>
<p><strong>5.优化表单row布局间距</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/issues/1092" target="_blank" rel="noopener noreferrer">#1092</a></p>
<h3 id="bug修复-12" tabindex="-1"><a class="header-anchor" href="#bug修复-12"><span>BUG修复</span></a></h3>
<ol>
<li>修复 <code v-pre>ModelTree</code> 删除节点时无法删除间隔一个层级以上的子节点问题</li>
<li>修复导出功能在部分环境可能会出现异常问题</li>
<li>修复表单联动(<code v-pre>load</code>)加载后初始值丢失的问题 <a href="https://github.com/jqhph/dcat-admin/pull/1103" target="_blank" rel="noopener noreferrer">@xqbumu</a></li>
<li>修复文件上传失败后显示提示信息异常问题</li>
<li>修复数据详情<code v-pre>Show</code>实例化函数如果传递模型，主键赋值错误的问题 <a href="https://github.com/jqhph/dcat-admin/pull/1112" target="_blank" rel="noopener noreferrer">@jisuye</a></li>
<li>修复表格<code v-pre>setConstraints</code>方法对快速编辑无效问题 <a href="https://github.com/jqhph/dcat-admin/issues/1119" target="_blank" rel="noopener noreferrer">#1119</a></li>
<li>修复在<code v-pre>iframe</code>页面中预览图片功能异常问题</li>
<li>修复<code v-pre>hasMany</code>以及<code v-pre>array</code>表单下删除使用<code v-pre>required</code>验证规则的字段后导致无法提交表单问题</li>
<li>修复表格<code v-pre>dialogTree</code>当顶级ID为字符串<code v-pre>0</code>时加载异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/1122" target="_blank" rel="noopener noreferrer">#1122</a></li>
</ol>
<h2 id="v2-0-20-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-20-beta"><span>v2.0.20-beta</span></a></h2>
<p>发布时间 2021/3/8</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.20-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-7" tabindex="-1"><a class="header-anchor" href="#功能改进-7"><span>功能改进</span></a></h3>
<p><strong>1.<code v-pre>selectTable</code>表单表格刷新时保留前页的数据状态</strong></p>
<p><code v-pre>selectTable</code>表单表格刷新或翻页后会保留前页选中或取消的数据状态</p>
<p><strong>2.<code v-pre>selectTable</code>表单设置显示字段名称功能优化</strong></p>
<p>在旧版本中，如果想要设置<code v-pre>selectTable</code>表单选中的字段或显示的字段，需要在<code v-pre>Renderable</code>对象中设置，非常的麻烦和不便，从当前版本开始，开发者可以直接通过下面的方法设置选中的字段或显示的字段</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">selectTable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user_id'</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">from</span><span class="token punctuation">(</span><span class="token class-name static-context">UserTable</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">pluck</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'full_name'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'id'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 第一个参数为显示的字段，第二个参数为选中后将保存到表单的字段</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 也可以直接使用下面的方法</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">selectTable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user_id'</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">from</span><span class="token punctuation">(</span><span class="token class-name static-context">UserTable</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">model</span><span class="token punctuation">(</span><span class="token class-name static-context">UserModel</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'id'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'full_name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.<code v-pre>selectTable</code>、<code v-pre>multipleSelectTable</code>、<code v-pre>radio</code>、<code v-pre>checkbox</code>表单增加<code v-pre>load</code>方法</strong></p>
<p>从当前版本开始，<code v-pre>selectTable</code>、<code v-pre>multipleSelectTable</code>、<code v-pre>radio</code>、<code v-pre>checkbox</code>也可以使用<code v-pre>load</code>方法联动<code v-pre>select</code>和<code v-pre>multipleSelect</code>表单</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">radio</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'type'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">options</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'category'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'categories/options'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">select</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'categories'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>接口<code v-pre>categories/options</code>返回格式如下</p>
<div class="language-json line-numbers-mode" data-highlighter="prismjs" data-ext="json" data-title="json"><pre v-pre class="language-json"><code><span class="line"><span class="token punctuation">[</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">9</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token property">"text"</span><span class="token operator">:</span> <span class="token string">"xxx"</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">21</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token property">"text"</span><span class="token operator">:</span> <span class="token string">"xxx"</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">,</span></span>
<span class="line">    ...</span>
<span class="line"><span class="token punctuation">]</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.增加菜单水平布局自动适应页面以及菜单高度变化功能</strong></p>
<p>启用菜单水平布局功能后，当页面高度或菜单高度发生变动时，页面会自适应、自行调整内容间距</p>
<hr>
<p><strong>5.增加表格<code v-pre>Grid::dropColumn()</code>方法用于删除设置的列</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$nameColumn</span> <span class="token operator">=</span> <span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 删除名称为 `name` 的列</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">dropColumn</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token comment">// 等同于</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">dropColumn</span><span class="token punctuation">(</span><span class="token variable">$nameColumn</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.增加<code v-pre>admin_javascript</code>函数</strong></p>
<p>此函数可用于往<code v-pre>php</code>的配置<code v-pre>array</code>中添加<code v-pre>JS</code>代码，用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'number'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">inputmask</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'oncomplete'</span> <span class="token operator">=></span> <span class="token function">admin_javascript</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'function () {</span>
<span class="line">        // 这里是js代码</span>
<span class="line">        alert('</span>inputmask complete<span class="token string single-quoted-string">');</span>
<span class="line">    }'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.<code v-pre>Form</code>表单底部可默认勾选<code v-pre>查看</code>、<code v-pre>继续编辑</code>、<code v-pre>继续创建</code>等选项功能</strong></p>
<p>用法如下 <a href="https://github.com/jqhph/dcat-admin/pull/1073" target="_blank" rel="noopener noreferrer">#1073</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">footer</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Footer</span> <span class="token variable">$footer</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 设置`查看`默认选中</span></span>
<span class="line">    <span class="token variable">$footer</span><span class="token operator">-></span><span class="token function">defaultViewChecked</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 设置`继续编辑`默认选中</span></span>
<span class="line">    <span class="token variable">$footer</span><span class="token operator">-></span><span class="token function">defaultEditingChecked</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 设置`继续创建`默认选中</span></span>
<span class="line">    <span class="token variable">$footer</span><span class="token operator">-></span><span class="token function">defaultCreatingChecked</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 设置`查看`默认选中</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">defaultViewChecked</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 设置`继续编辑`默认选中</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">defaultEditingChecked</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 设置`继续创建`默认选中</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">defaultCreatingChecked</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug" tabindex="-1"><a class="header-anchor" href="#bug"><span>BUG</span></a></h3>
<ol>
<li>修复表格使用关联关系字段排序时必须先<code v-pre>with</code>问题</li>
<li>修复同个页面无法同时渲染多个异步组件问题</li>
<li>修复树形表格下删除子节点数据后跳转异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/1071" target="_blank" rel="noopener noreferrer">#1071</a></li>
<li>修复表格导出字段中存在空数组时导出异常问题</li>
<li>修复表单多图上传使用<code v-pre>sortable</code>功能进行排序会导致页面的图片元素消失不见问题</li>
<li>修复表单字段<code v-pre>disable</code>方法设置<code v-pre>false</code>无效问题</li>
<li>修复<code v-pre>multipleSelect</code>表单使用<code v-pre>load</code>联动加载时无法把所有选中选项传入接口问题 <a href="https://github.com/jqhph/dcat-admin/issues/1076" target="_blank" rel="noopener noreferrer">#1076</a></li>
<li>修复表格规格选择器存在多个0开头选项时选中功能异常问题</li>
</ol>
<h3 id="bug-1" tabindex="-1"><a class="header-anchor" href="#bug-1"><span>BUG</span></a></h3>
<p>1. 修复表格使用关联关系字段排序时必须先<code v-pre>with</code>问题<br>
2. 修复同个页面无法同时渲染多个异步组件问题<br>
3. 修复树形表格下删除子节点数据后跳转异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/1071" target="_blank" rel="noopener noreferrer">#1071</a><br>
4. 修复表格导出字段中存在空数组时导出异常问题<br>
5. 修复表单多图上传使用<code v-pre>sortable</code>功能进行排序会导致页面的图片元素消失不见问题<br>
6. 修复表单字段<code v-pre>disable</code>方法设置<code v-pre>false</code>无效问题<br>
7. 修复<code v-pre>multipleSelect</code>表单使用<code v-pre>load</code>联动加载时无法把所有选中选项传入接口问题 <a href="https://github.com/jqhph/dcat-admin/issues/1076" target="_blank" rel="noopener noreferrer">#1076</a><br>
8. 修复表格规格选择器存在多个0开头选项时选中功能异常问题</p>
<h2 id="v2-0-19-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-19-beta"><span>v2.0.19-beta</span></a></h2>
<p>发布时间 2021/2/21</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.19-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-13" tabindex="-1"><a class="header-anchor" href="#bug修复-13"><span>BUG修复</span></a></h3>
<p>1. 修复非超管角色下请求 <code v-pre>内置api</code> 时提示 <code v-pre>无权访问</code> 问题<br>
2. 修复在弹窗中使用时间范围表单报错问题</p>
<h2 id="v2-0-18-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-18-beta"><span>v2.0.18-beta</span></a></h2>
<p>发布时间 2021/2/20</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.18-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-8" tabindex="-1"><a class="header-anchor" href="#功能改进-8"><span>功能改进</span></a></h3>
<p><strong>1.增加菜单顶部横向布局 (Horizontal)</strong></p>
<p>设置配置参数 <code v-pre>admin.layout.horizontal_menu</code> 的值为 <code v-pre>true</code> 开启此功能，效果如下</p>
<p><img src="https://cdn.learnku.com/uploads/images/202102/20/38389/SpmXMujJ3D.png!large" alt=""></p>
<p><strong>2.权限中间件以及跳过登陆判断时可以填写路由别名并且无需增加前缀</strong></p>
<p>配置文件以及权限设置路由别名时无需填写路由前缀</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">    <span class="token string single-quoted-string">'permission'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 跳过权限判断</span></span>
<span class="line">        <span class="token string single-quoted-string">'except'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token comment">// 可以直接填写路由别名，并且无需写路由前缀</span></span>
<span class="line">            <span class="token string single-quoted-string">'custom.users'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.数据表格行数据增加 <code v-pre>_index</code> 字段用于保存行序号</strong></p>
<p>数据表格行数据增加 <code v-pre>_index</code> 字段用于保存行序号，从 <code v-pre>0</code> 开始，用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 在 display 回调中使用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'序号'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">display</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">_index</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 在行操作 action 中使用</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">actions</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$actions</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$index</span> <span class="token operator">=</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">_index</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.重命名 markdown 组件静态资源别名，避免与自定义 blade 标签产生冲突</strong></p>
<p><strong>5.增加配置参数 <code v-pre>admin.menu.default_icon</code> 用于设置默认菜单图标</strong></p>
<p><code v-pre>admin.menu.default_icon</code> 用于设置菜单默认图标，默认值为 <code v-pre>feather icon-circle</code></p>
<p><strong>6.增加新的区块位置 <code v-pre>NAVBAR_BEFORE</code> 以及 <code v-pre>NAVBAR_AFTER</code></strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Admin</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 往顶部导航栏前输出内容</span></span>
<span class="line"><span class="token function">admin_inject_section</span><span class="token punctuation">(</span><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token constant">SECTION</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'NAVBAR_BEFORE'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token function">view</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 往顶部导航栏后输出内容</span></span>
<span class="line"><span class="token function">admin_inject_section</span><span class="token punctuation">(</span><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token constant">SECTION</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'NAVBAR_AFTER'</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token function">view</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.优化表格字段选择器代码</strong></p>
<h3 id="bug修复-14" tabindex="-1"><a class="header-anchor" href="#bug修复-14"><span>BUG修复</span></a></h3>
<ol>
<li>修复扩展管理页面<code v-pre>new</code>标签显示异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/1044" target="_blank" rel="noopener noreferrer">#1044</a></li>
<li>修复文件上传成功后直接删除报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/1058" target="_blank" rel="noopener noreferrer">#1058</a></li>
<li>修复 <code v-pre>Form::number</code> 表单在使用 <code v-pre>min</code> 和 <code v-pre>max</code> 方法后输入值异常问题</li>
</ol>
<h2 id="v2-0-17-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-17-beta"><span>v2.0.17-beta</span></a></h2>
<p>发布时间 2021/2/5</p>
<p>升级方法，逐步执行以下命令，并清除浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.17-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="破坏性变动" tabindex="-1"><a class="header-anchor" href="#破坏性变动"><span>破坏性变动</span></a></h3>
<p><strong>1.路由别名调整</strong><br>
所有后台的路由别名都会自动增加前缀，需要通过 <code v-pre>admin_route</code> 函数获取路由URL，<code v-pre>admin_route</code> 可以完全代替 Laravel 内建的 <code v-pre>route</code> 方法，且支持单一方法请求的路由别名，以下是一些合法范例：</p>
<p><code v-pre>admin_route('records')</code>，资源路由和方法路由的别名。</p>
<p><code v-pre>admin_route('records',['id' =&gt; 1])</code>，附带请求参数。</p>
<h3 id="功能改进-9" tabindex="-1"><a class="header-anchor" href="#功能改进-9"><span>功能改进</span></a></h3>
<p><strong>1.优化表格排序功能</strong></p>
<p>支持<code v-pre>orderBy</code>直接使用关联关系表字段进行排序，注意这里仅支持<code v-pre>一对一</code>以及<code v-pre>一对多</code>关联关系</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">model</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">orderBy</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.age'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>2.增加模型树以及树形表格自定义顶级<code v-pre>parent_id</code>值功能</strong></p>
<p>模型树以及树形表格可以在<code v-pre>model</code>中自定义顶级<code v-pre>parent_id</code>值，默认值为<code v-pre>0</code></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">Category</span> <span class="token keyword">extends</span> <span class="token class-name">Model</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">use</span> <span class="token package">ModelTree</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token comment">// 设置默认 parent_id 为 A</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$defaultParentId</span> <span class="token operator">=</span> <span class="token string single-quoted-string">'A'</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.数据详情 <code v-pre>file</code> 支持展示多文件</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/985" target="_blank" rel="noopener noreferrer">#985</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$show</span><span class="token operator">-></span><span class="token function">field</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">files</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>效果</p>
<p><img src="https://cdn.learnku.com/uploads/images/202102/02/38389/B0a2qZEBUL.png!large" alt=""></p>
<p><strong>4.<code v-pre>Form::input</code>支持数组批量设置</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">submitted</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">input</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'k1'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'v1'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'k2'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'v2'</span> <span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5.扩展管理支持<code v-pre>logo</code>以及<code v-pre>别名展示</code></strong></p>
<p>详细用法参考文档 <a href="https://learnku.com/docs/dcat-admin/2.x/beta-version-update-log/extension-dev.md#logo" target="_blank" rel="noopener noreferrer">扩展</a></p>
<p><strong>6.增加admin_route方法根据别名获取URL</strong></p>
<p><code v-pre>app/Admin/routes.php</code>路由注册如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token class-name static-context">Route</span><span class="token operator">::</span><span class="token function">group</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'prefix'</span>        <span class="token operator">=></span> <span class="token function">config</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'admin.route.prefix'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'namespace'</span>     <span class="token operator">=></span> <span class="token function">config</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'admin.route.namespace'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'middleware'</span>    <span class="token operator">=></span> <span class="token function">config</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'admin.route.middleware'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Router</span> <span class="token variable">$router</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 设置别名</span></span>
<span class="line">    <span class="token variable">$router</span><span class="token operator">-></span><span class="token function">resource</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'users'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'UserController'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'names'</span> <span class="token operator">=></span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'index'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'my-users'</span><span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>根据别名获取URL</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 获取url</span></span>
<span class="line"><span class="token variable">$url</span> <span class="token operator">=</span> <span class="token function">admin_route</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'my-users'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 判断路由</span></span>
<span class="line"><span class="token variable">$isUsers</span> <span class="token operator">=</span> <span class="token function">request</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">routeIs</span><span class="token punctuation">(</span><span class="token function">admin_route_name</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'users'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>8.JsonResponse::location 允许不传参</strong></p>
<p>如果不传参会在<code v-pre>1</code>秒之后自动刷新当前页面</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">return</span> <span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">json</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">success</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'操作成功'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">location</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>9.页面布局Layout\Column支持等宽布局</strong></p>
<p>当列宽度设置为<code v-pre>0</code>时会使用等宽布局 <a href="https://github.com/jqhph/dcat-admin/pull/1018" target="_blank" rel="noopener noreferrer">#1018</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Layout<span class="token punctuation">\</span>Row</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Layout<span class="token punctuation">\</span>Content</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">return</span> <span class="token class-name static-context">Content</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">body</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Row</span> <span class="token variable">$row</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token function">view</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>10.页面布局Layout\Row支持no-gutters属性</strong></p>
<p><code v-pre>.row</code>上带有<code v-pre>margin-left: -15px;margin-right: -15px;</code>属性，你可以在<code v-pre>.row</code>上上定义<code v-pre>.no-gutters</code>属性，从而消除这个属性，使页面不会额外宽出<code v-pre>30px</code>，即<code v-pre>&lt;div class=&quot;row no-gutters&quot;...</code></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$content</span><span class="token operator">-></span><span class="token function">row</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Row</span> <span class="token variable">$row</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 启用 no-gutters</span></span>
<span class="line">    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">noGutters</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Column</span> <span class="token variable">$column</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$column</span><span class="token operator">-></span><span class="token function">row</span><span class="token punctuation">(</span><span class="token variable">$this</span><span class="token operator">-></span><span class="token function">card</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'col-md-12'</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'#4DB6AC'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token variable">$column</span><span class="token operator">-></span><span class="token function">row</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Row</span> <span class="token variable">$row</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">// 启用 no-gutters</span></span>
<span class="line">            <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">noGutters</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">            <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">card</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'col-md-4'</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'#80CBC4'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">            <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">card</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'col-md-4'</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'#4DB6AC'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">            <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Column</span> <span class="token variable">$column</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">                <span class="token variable">$column</span><span class="token operator">-></span><span class="token function">row</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Row</span> <span class="token variable">$row</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">                    <span class="token comment">// 启用 no-gutters</span></span>
<span class="line">                    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">noGutters</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">                    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">,</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">card</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'col-md-6'</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'#26A69A'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">                    <span class="token variable">$row</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">,</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">card</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'col-md-6'</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'#26A69A'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">            <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>效果如下</p>
<p><img src="https://cdn.learnku.com/uploads/images/202102/05/38389/4YlO8aOPCW.jpg!large" alt=""></p>
<p><strong>11.表格删除数据后保留URL的get参数</strong></p>
<p>在之前的版本中，删除数据后会丢失<code v-pre>URL</code>的<code v-pre>get</code>参数，导致跳转回表格第一页，这个版本对这个功能进行了优化，删除后依然会保留<code v-pre>URL</code>的<code v-pre>get</code>参数 <a href="https://github.com/jqhph/dcat-admin/issues/961" target="_blank" rel="noopener noreferrer">#961</a></p>
<p><strong>12.重构文件上传前端代码</strong></p>
<p>此功能为技术性优化，这个版本对文件上传前端代码进行了重构、拆分代码，使其更易阅读和维护</p>
<h3 id="bug修复-15" tabindex="-1"><a class="header-anchor" href="#bug修复-15"><span>BUG修复</span></a></h3>
<ol>
<li>修复<code v-pre>MultipleSelect</code>表单样式异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/967" target="_blank" rel="noopener noreferrer">#967</a></li>
<li>修复加载<code v-pre>markdown</code>组件后使用<code v-pre>select2</code>表单异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/990" target="_blank" rel="noopener noreferrer">#990</a></li>
<li>修复文件上传在<code v-pre>Linux</code>服务器下保存繁体中文文件名丢失问题 <a href="https://github.com/jqhph/dcat-admin/issues/993" target="_blank" rel="noopener noreferrer">#993</a></li>
<li>修复 <code v-pre>Widgets\Dropdown::click</code> 无法显示默认选项问题</li>
<li>修复<code v-pre>form</code>表单中的<code v-pre>number</code>组件文本内容为空时点击加减按钮出现<code v-pre>NaN</code>问题 <a href="https://github.com/jqhph/dcat-admin/issues/995" target="_blank" rel="noopener noreferrer">#995</a></li>
<li>修复图片预览失败提示无法使用翻译文件问题</li>
<li>修复一对一关联关系<code v-pre>Range</code>表单使用验证规则判断异常问题</li>
<li>修复多应用情况下路由别名冲突的问题</li>
</ol>
<h2 id="v2-0-16-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-16-beta"><span>v2.0.16-beta</span></a></h2>
<p>发布时间 2021/1/11</p>
<p>升级方法，逐步执行以下命令，并清理浏览器缓存</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.16-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="破坏性变动-1" tabindex="-1"><a class="header-anchor" href="#破坏性变动-1"><span>破坏性变动</span></a></h3>
<p>*<em>1.表单字段的 <code v-pre>disableHorizontal</code> 调整为 <code v-pre>horizontal</code> *</em></p>
<p>更改表单字段布局方式为<code v-pre>horizontal</code>，此功能默认启用，用法如下</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 禁用 horizontal 布局</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">horizontal</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-10" tabindex="-1"><a class="header-anchor" href="#功能改进-10"><span>功能改进</span></a></h3>
<p><strong>1.增强表格字段排序(sortable)功能</strong></p>
<p>使表格字段支持关联关系表字段以及<code v-pre>json</code>字段的排序</p>
<blockquote>
<p>注意，关联关系仅支持<code v-pre>hasOne</code>以及<code v-pre>belongsTo</code>两种类型的字段排序，并且不支持多层级嵌套！</p>
</blockquote>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 关联关系表字段排序</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.age'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">sortable</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 指定需要排序的字段名称</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'my_age'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">sortable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.age'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// json字段排序</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'options.price'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">sortable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'options->price'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token comment">// 关联关系表的 json 字段排序</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.options.price'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">sortable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.options->price'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>支持<code v-pre>MySql</code>的<code v-pre>order by cast(`{field}` as {type})</code>用法</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.age'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">sortable</span><span class="token punctuation">(</span><span class="token constant">null</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'SIGNED'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.options.price'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">sortable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.options->price'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'SIGNED'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>2.增加 admin_exit 函数，用于代替 exit</strong></p>
<p><code v-pre>admin_exit</code> 用于中断程序执行，并响应数据到浏览器进行显示，用于代替 <code v-pre>exit</code> 和 <code v-pre>die</code>，下面简单介绍下用法</p>
<p>用法1，返回 <code v-pre>Content</code> 布局对象，此用法可用于返回错误信息显示到前端</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Widgets<span class="token punctuation">\</span>Alert</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Layout<span class="token punctuation">\</span>Content</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 中断程序，并显示自定义页面到前端</span></span>
<span class="line"><span class="token function">admin_exit</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name static-context">Content</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">title</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'标题'</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">description</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'描述'</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">body</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'页面内容1'</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">body</span><span class="token punctuation">(</span><span class="token class-name static-context">Alert</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'服务器出错了~'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'Error'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">danger</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>效果如下</p>
<p><img src="https://cdn.learnku.com/uploads/images/202101/11/38389/FLg6C7kwRq.png!large" alt=""></p>
<p>用法2，返回 <code v-pre>json</code> 格式数据，此用法经常用于表单提交数据的<code v-pre>api</code>请求拦截，或<code v-pre>Action</code>的<code v-pre>api</code>请求拦截</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Admin</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token function">admin_exit</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">json</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">success</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'成功了'</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">refresh</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">            <span class="token operator">...</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 当然也可以直接响应数组</span></span>
<span class="line"><span class="token function">admin_exit</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">   <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>用法3，直接相应<code v-pre>Response</code>对象或字符串</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token function">admin_exit</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'Hello world'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token function">admin_exit</span><span class="token punctuation">(</span><span class="token function">response</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'Hello world'</span><span class="token punctuation">,</span> <span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.增加 Show\Field::bool() 和 Show\Field::bold() 方法</strong></p>
<p>字段值为真显示 <code v-pre>✓</code>, 否则显示 <code v-pre>✗</code> <a href="https://github.com/jqhph/dcat-admin/pull/940" target="_blank" rel="noopener noreferrer">#940</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$show</span><span class="token operator">-></span><span class="token function">field</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token keyword type-declaration">bool</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>字段值加粗显示</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$show</span><span class="token operator">-></span><span class="token function">field</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">bold</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 指定颜色</span></span>
<span class="line"><span class="token variable">$show</span><span class="token operator">-></span><span class="token function">field</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">bold</span><span class="token punctuation">(</span><span class="token function">admin_color</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">primary</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.增加 Form\Footer::view() 方法</strong></p>
<p>通过 <code v-pre>Form\Footer::view()</code> 方法可以自定义数据表单的底部视图 <a href="https://github.com/jqhph/dcat-admin/pull/957" target="_blank" rel="noopener noreferrer">#957</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">footer</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$footer</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$footer</span><span class="token operator">-></span><span class="token function">view</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5.增加表单默认显示指定 Tab 功能</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 默认显示标题为 标题2 的 Tab</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">getTab</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">active</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'标题2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token comment">// 也可以指定偏移量</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">getTab</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">activeByIndex</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">tab</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'标题1'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">tab</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'标题2'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.增加表单 Form\Row::horizontal() 方法</strong></p>
<p>设置布局为 <code v-pre>horizontal</code></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">row</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name class-name-fully-qualified type-declaration">Form<span class="token punctuation">\</span>Row</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">horizontal</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>7.表格 Modal 增加自定义图标功能</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">modal</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$modal</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 自定义图标</span></span>
<span class="line">    <span class="token variable">$modal</span><span class="token operator">-></span><span class="token function">icon</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'feather icon-x'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">return</span> <span class="token operator">...</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>8.增加路由域名限制配置</strong></p>
<p>通过配置参数<code v-pre>admin.route.domain</code>可以限制路由的域名, 打开配置文件 <code v-pre>config/admin.php</code></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">    <span class="token string single-quoted-string">'route'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'domain'</span> <span class="token operator">=></span> <span class="token function">env</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'ADMIN_ROUTE_DOMAIN'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'prefix'</span> <span class="token operator">=></span> <span class="token function">env</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'ADMIN_ROUTE_PREFIX'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'admin'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'namespace'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'App\\Admin\\Controllers'</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'middleware'</span> <span class="token operator">=></span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'web'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'admin'</span><span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>9.增加 admin.session 中间件的启用或禁用配置</strong></p>
<p>从<code v-pre>2.0</code>的版本之后 <code v-pre>admin.session</code> 中间件不再默认启用，如果您的应用同时有前台和后台，则需要开启 <code v-pre>admin.session</code> 中间件，否则会造成前后台 <code v-pre>session</code> 冲突问题。</p>
<p>把配置参数 <code v-pre>admin.route.enable_session_middleware</code> 的值设置为 <code v-pre>true</code> 即可开启</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">    <span class="token string single-quoted-string">'route'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'domain'</span> <span class="token operator">=></span> <span class="token function">env</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'ADMIN_ROUTE_DOMAIN'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'prefix'</span> <span class="token operator">=></span> <span class="token function">env</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'ADMIN_ROUTE_PREFIX'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'admin'</span><span class="token punctuation">)</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'namespace'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'App\\Admin\\Controllers'</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token string single-quoted-string">'middleware'</span> <span class="token operator">=></span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'web'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'admin'</span><span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 开启 admin.session 中间件</span></span>
<span class="line">        <span class="token string single-quoted-string">'enable_session_middleware'</span> <span class="token operator">=></span> <span class="token constant boolean">true</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-16" tabindex="-1"><a class="header-anchor" href="#bug修复-16"><span>BUG修复</span></a></h3>
<ol>
<li>修复数据表格<code v-pre>Grid::header</code>以及<code v-pre>Grid::footer</code>回调的第一个参数中<code v-pre>Model</code>被转化为<code v-pre>array</code>格式问题</li>
<li>修复切换主题时文件上传按钮颜色无法跟着改变问题 <a href="https://github.com/jqhph/dcat-admin/issues/938" target="_blank" rel="noopener noreferrer">#938</a></li>
<li>修复 <code v-pre>Widgets\Table</code> 构造方法第三个参数设置无效问题</li>
<li>修复 <code v-pre>app/Admin/bootstrap.php</code> 中使用 <code v-pre>config(['admin.layout.color' =&gt; '...'])</code> 覆盖主题色可能无效问题</li>
<li>修复数据表格过滤器重置关联关系表单字段无效问题 <a href="https://github.com/jqhph/dcat-admin/issues/949" target="_blank" rel="noopener noreferrer">#949</a></li>
<li>修复表格过滤器 <code v-pre>group</code> 功能显示异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/929" target="_blank" rel="noopener noreferrer">#929</a></li>
<li>修复当页面存在多个 <code v-pre>selectTable</code> 表单时所有弹窗都只显示第一个设置的 <code v-pre>title</code> 问题 <a href="https://github.com/jqhph/dcat-admin/issues/926" target="_blank" rel="noopener noreferrer">#926</a></li>
</ol>
<h2 id="v2-0-15-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-15-beta"><span>v2.0.15-beta</span></a></h2>
<p>发布时间 2021/1/3</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.15-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-11" tabindex="-1"><a class="header-anchor" href="#功能改进-11"><span>功能改进</span></a></h3>
<p><strong>1.升级select2到v4.1.x-beta版本</strong></p>
<p><code v-pre>select</code>组件升级至<code v-pre>v4.1.x-beta</code>，使<code v-pre>tags</code>表单体验更好，并支持了多国语言翻译。</p>
<p><strong>2.Widgets/Modal增加弹窗垂直居中以及可滚动功能</strong></p>
<p>用法如下 <a href="https://github.com/jqhph/dcat-admin/pull/901" target="_blank" rel="noopener noreferrer">#901</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$modal</span> <span class="token operator">=</span> <span class="token class-name static-context">Modal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">xl</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">centered</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 设置弹窗垂直居中</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">scrollable</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 设置弹窗内容可滚动</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">title</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">body</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.<code v-pre>Admin::requiredAssets</code>支持传递动态参数</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Admin</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 注册前端组件别名</span></span>
<span class="line"><span class="token comment">// {lang} 为动态参数</span></span>
<span class="line"><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">asset</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">alias</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'@test'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'js'</span> <span class="token operator">=></span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'/vendor/test/js/{lang}.min.js'</span><span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// {lang} 会被替换为 zh_CN</span></span>
<span class="line"><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">requireAssets</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'@test'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'lang'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'zh_CN'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token comment">// 也可以这样使用</span></span>
<span class="line"><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">requireAssets</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'@test?lang=zh_CN'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-17" tabindex="-1"><a class="header-anchor" href="#bug修复-17"><span>Bug修复</span></a></h3>
<ol>
<li>修复表单<code v-pre>block</code>布局无法保存数据问题 <a href="https://github.com/jqhph/dcat-admin/issues/883" target="_blank" rel="noopener noreferrer">#883</a></li>
<li>修复<code v-pre>hasMany</code>表单下使用<code v-pre>currency</code>失效问题 <a href="https://github.com/jqhph/dcat-admin/issues/886" target="_blank" rel="noopener noreferrer">#886</a></li>
<li>修复数据表单保存后自动跳转到详情页问题 <a href="https://github.com/jqhph/dcat-admin/issues/893" target="_blank" rel="noopener noreferrer">#893</a></li>
<li>修复<code v-pre>editor</code>表单无法清空数据问题 <a href="https://github.com/jqhph/dcat-admin/issues/895" target="_blank" rel="noopener noreferrer">#895</a></li>
<li>修复<code v-pre>hasMany</code>表单下使用<code v-pre>tags</code>的<code v-pre>required</code>验证异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/905" target="_blank" rel="noopener noreferrer">#905</a></li>
<li>修复多文件上传表单删除单个文件时会导致全部文件被清空问题 <a href="https://github.com/jqhph/dcat-admin/issues/914" target="_blank" rel="noopener noreferrer">#914</a></li>
<li>修复表格字段无法使用模型访问器问题</li>
</ol>
<h2 id="v2-0-14-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-14-beta"><span>v2.0.14-beta</span></a></h2>
<p>发布时间 2020/12/24</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.14-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-12" tabindex="-1"><a class="header-anchor" href="#功能改进-12"><span>功能改进</span></a></h3>
<p><strong>1.优化文件上传失败错误信息提示</strong></p>
<p>在旧版本中，文件上传失败的错误提示信息不太明确，导致难以定义错误原因，所以在这个版本中对错误提示进行了优化，一旦文件上传失败会显示具体原因。</p>
<h3 id="bug修复-18" tabindex="-1"><a class="header-anchor" href="#bug修复-18"><span>Bug修复</span></a></h3>
<p>1. 修复表格字段与模型<code v-pre>casts</code>属性产生冲突，以及<code v-pre>display</code>闭包中使用字符串拼接显示异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/876" target="_blank" rel="noopener noreferrer">#876</a><br>
2. 修复表单动态显示功能无法使用问题 <a href="https://github.com/jqhph/dcat-admin/issues/879" target="_blank" rel="noopener noreferrer">#879</a><br>
3. 修复表单使用<code v-pre>Block</code>布局时无法显示编辑数据问题 <a href="https://github.com/jqhph/dcat-admin/issues/877" target="_blank" rel="noopener noreferrer">#877</a></p>
<h2 id="v2-0-13-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-13-beta"><span>v2.0.13-beta</span></a></h2>
<p>发布时间 2020/12/23</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.13-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-19" tabindex="-1"><a class="header-anchor" href="#bug修复-19"><span>Bug修复</span></a></h3>
<p>1. 修复表格展示关联关系字段当关联数据不存在时有可能报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/867" target="_blank" rel="noopener noreferrer">#867</a><br>
2. 修复当表格使用数据仓库返回数组或非模型<code v-pre>collection</code>时<code v-pre>display</code>方法无效问题 <a href="https://github.com/jqhph/dcat-admin/issues/869" target="_blank" rel="noopener noreferrer">#869</a></p>
<h2 id="v2-0-12-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-12-beta"><span>v2.0.12-beta</span></a></h2>
<p>发布时间 2020/12/22</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.12-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="破坏性变动-2" tabindex="-1"><a class="header-anchor" href="#破坏性变动-2"><span>破坏性变动</span></a></h3>
<p><strong>1.图片/文件上传表单<code v-pre>removeable</code>重命名为<code v-pre>removable</code></strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">removable</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="功能改进-13" tabindex="-1"><a class="header-anchor" href="#功能改进-13"><span>功能改进</span></a></h3>
<p><strong>1.支持PHP8.0</strong></p>
<p><strong>2.图片/文件上传表单支持监听WebUploader事件</strong></p>
<p>通过 <code v-pre>on</code> 方法可以监听 <a href="http://fex.baidu.com/webuploader/doc/index.html#WebUploader_Uploader_events" target="_blank" rel="noopener noreferrer">WebUploader文件上传相关事件</a></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'startUpload'</span><span class="token punctuation">,</span> <span class="token operator">&lt;&lt;</span><span class="token operator">&lt;</span><span class="token constant">JS</span></span>
<span class="line">        <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            console<span class="token operator">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'文件开始上传...'</span><span class="token punctuation">,</span> this<span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">            <span class="token comment">// 上传文件前附加自定义参数到文件上传接口</span></span>
<span class="line">            this<span class="token operator">.</span>uploader<span class="token operator">.</span>options<span class="token operator">.</span>formData<span class="token punctuation">[</span><span class="token string single-quoted-string">'custom_field'</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token string single-quoted-string">'...'</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span></span>
<span class="line"><span class="token constant">JS</span></span>
<span class="line">    <span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'uploadFinished'</span><span class="token punctuation">,</span> <span class="token operator">&lt;&lt;</span><span class="token operator">&lt;</span><span class="token constant">JS</span></span>
<span class="line">        <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            console<span class="token operator">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'文件上传完毕'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span></span>
<span class="line"><span class="token constant">JS</span></span>
<span class="line">    <span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">//         </span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.监听文件上传成功或文件被删除时产生的变动</strong></p>
<p>通过以下方法可以监听文件<strong>上传成功</strong>或文件<strong>被删除</strong>时产生的变动</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$file</span> <span class="token operator">=</span> <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">script</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token operator">&lt;&lt;</span><span class="token operator">&lt;</span><span class="token class-name type-declaration">JS</span></span>
<span class="line">$<span class="token punctuation">(</span><span class="token string single-quoted-string">'{$file->getElementClassSelector()} .file-input'</span><span class="token punctuation">)</span><span class="token operator">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'change'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    console<span class="token operator">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'文件发生变动'</span><span class="token punctuation">,</span> this<span class="token operator">.</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token constant">JS</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.允许在uploading事件中拦截并响应错误信息</strong></p>
<p>从这个版本开始支持在表单的 <code v-pre>uploading</code> 事件中拦截文件上传并支持响应错误信息到前端</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">uploading</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">Form</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">response</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'文件上传失败，请重试！'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5.监听selectTable选中值变动</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$selectTable</span> <span class="token operator">=</span> <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">selectTable</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">from</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token class-name static-context">Admin</span><span class="token operator">::</span><span class="token function">script</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token operator">&lt;&lt;</span><span class="token operator">&lt;</span><span class="token class-name type-declaration">JS</span></span>
<span class="line">$<span class="token punctuation">(</span><span class="token string single-quoted-string">'{$selectTable->getElementClassSelector()} input[type="hidden"]'</span><span class="token punctuation">)</span><span class="token operator">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'change'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    console<span class="token operator">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'选中值发生变化'</span><span class="token punctuation">,</span> this<span class="token operator">.</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token constant">JS</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.调整树状表格无数据返回，取消返回404状态码</strong></p>
<p><strong>7.调整表格displayer类的row属性值类型为model</strong></p>
<p><strong>8.暗黑模式细节优化</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">modal</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// $this 指向 model 对象</span></span>
<span class="line">    <span class="token function">dd</span><span class="token punctuation">(</span><span class="token variable">$this</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">actions</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// $this 指向 model 对象</span></span>
<span class="line">    <span class="token function">dd</span><span class="token punctuation">(</span><span class="token variable">$this</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>9.优化卡片中图表显示溢出的问题</strong></p>
<p><a href="https://github.com/jqhph/dcat-admin/pull/822" target="_blank" rel="noopener noreferrer">#822</a></p>
<p><strong>10.widget组件增加when方法</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$modal</span> <span class="token operator">=</span> <span class="token class-name class-name-fully-qualified static-context">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Widgets<span class="token punctuation">\</span>Modal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">when</span><span class="token punctuation">(</span><span class="token variable">$condition</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$modal</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token comment">// 当 $condition 的值为 真 时，会执行闭包里面的逻辑</span></span>
<span class="line">        <span class="token variable">$modal</span><span class="token operator">-></span><span class="token function">xl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">body</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token operator">-></span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-20" tabindex="-1"><a class="header-anchor" href="#bug修复-20"><span>Bug修复</span></a></h3>
<p>1. 修复 <code v-pre>Grid\Filter::group</code> 无法保持选择状态问题 <a href="https://github.com/jqhph/dcat-admin/pull/793" target="_blank" rel="noopener noreferrer">#739</a><br>
2. 修复 <code v-pre>Form::hasMany</code> 表单条目删除后仍然验证 <code v-pre>required</code> 问题 <a href="https://github.com/jqhph/dcat-admin/pull/795" target="_blank" rel="noopener noreferrer">#795</a><br>
3. 修复 地图 表单无法使用问题<br>
4. 修复当生成 <code v-pre>composer</code> 类映射文件且类文件被删除的情况下使用 <code v-pre>guessClassFileName</code> 会报错问题<br>
5. 修复数据导出使用 <code v-pre>Fetched</code> 事件报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/815" target="_blank" rel="noopener noreferrer">#815</a><br>
6. 修复设置 <code v-pre>Grid name</code> 之后无法重置 <code v-pre>filter</code> 问题<br>
7. 修复 <code v-pre>select2</code> 无法自动使用中文语言包问题 <a href="https://github.com/jqhph/dcat-admin/issues/839" target="_blank" rel="noopener noreferrer">#839</a><br>
8. 修复表单勾选 <code v-pre>继续创建</code> 以及 <code v-pre>继续编辑</code> 跳转路由错误问题 <a href="https://github.com/jqhph/dcat-admin/issues/814" target="_blank" rel="noopener noreferrer">#814</a><br>
9. 修复一对一关联关系 <code v-pre>range</code> 表单设置 <code v-pre>rules</code> 无效问题<br>
10. 修复当启用 <code v-pre>fixColumns</code> 时，时间筛选下拉会被遮挡问题 <a href="https://github.com/jqhph/dcat-admin/issues/833" target="_blank" rel="noopener noreferrer">#833</a><br>
11. 修复菜单使用<code v-pre>fa</code>图标无法自动对齐问题 <a href="https://github.com/jqhph/dcat-admin/pull/758" target="_blank" rel="noopener noreferrer">#758</a><br>
12. 修复表单 <code v-pre>row</code> 布局下使用 <code v-pre>hasMany</code> 提交报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/801" target="_blank" rel="noopener noreferrer">#801</a><br>
13. 修复表单 <code v-pre>hasMany</code> 无法使用 <code v-pre>select</code> 联动问题 <a href="https://github.com/jqhph/dcat-admin/issues/769" target="_blank" rel="noopener noreferrer">#769</a></p>
<h2 id="v2-0-11-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-11-beta"><span>v2.0.11-beta</span></a></h2>
<p>发布时间 2020/12/06</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.11-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span> <span class="token comment"># 表结构有变动</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="bug修复-21" tabindex="-1"><a class="header-anchor" href="#bug修复-21"><span>Bug修复</span></a></h3>
<p>1. 修复使用 <code v-pre>pjax</code> 重复刷新页面可能导致 <code v-pre>Dcat.init</code> 监听失效问题<br>
2. 修复 <code v-pre>admin:export-seed --users</code> 会生成多余代码问题<br>
3. 修复表单编辑页面保存后跳转异常问题<br>
4. 修复表单页面选择继续编辑会导致 <code v-pre>hasMany</code> 重复添加数据问题<br>
5. 修复 <code v-pre>select</code> 表单联动后原 <code v-pre>select2 config</code> 丢失问题 <a href="https://github.com/jqhph/dcat-admin/issues/779" target="_blank" rel="noopener noreferrer">#779</a><br>
6. 修复 <code v-pre>map</code> 表单加载异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/764" target="_blank" rel="noopener noreferrer">#764</a><br>
7. 修复批量删除功能删除数据后无法自动刷新页面问题<br>
8. 修复 <code v-pre>hasMany</code> 表单编辑页面无法正常展示 <code v-pre>row</code> 以及 <code v-pre>column</code> 布局问题<br>
9. 修复 <code v-pre>Dcat.init</code> 监听会被异步弹窗解绑问题<br>
10. 修复表格工具栏下拉菜单会被固定列表格遮挡问题 <a href="https://github.com/jqhph/dcat-admin/issues/728" target="_blank" rel="noopener noreferrer">#728</a><br>
11. 修复禁用 <code v-pre>showColumnSelector</code> 时仍然会读取缓存内容问题</p>
<h3 id="功能改进-14" tabindex="-1"><a class="header-anchor" href="#功能改进-14"><span>功能改进</span></a></h3>
<p><strong>1.Form::divider 增加 title 参数</strong></p>
<p>增加 <code v-pre>title</code> 参数用于在分割线中间显示标题功能，用法</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">divider</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'标题'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>2.Grid::footer以及Grid::header调整为支持多次回调</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">header</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">header</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">header</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>3.优化表格规格筛选器以及select表单样式</strong></p>
<h2 id="v2-0-10-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-10-beta"><span>v2.0.10-beta</span></a></h2>
<p>发布时间 2020/11/29</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.10-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span> <span class="token comment"># 表结构有变动</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="功能改进-15" tabindex="-1"><a class="header-anchor" href="#功能改进-15"><span>功能改进</span></a></h3>
<p><strong>1.增加表单右上角提示窗展示字段验证错误信息</strong></p>
<p>此功能默认开启，可以通过<code v-pre>validationErrorToastr</code>方法禁用</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">validationErrorToastr</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>2.增加 Tree::maxDepth 方法用于限制模型树最大层级</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$tree</span><span class="token operator">-></span><span class="token function">maxDepth</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>3.优化导出功能，支持标题设置关联关系字段以及自动读取grid表格列的标题</strong></p>
<p>在当前版本中导出列默认与<code v-pre>column</code>列一致，不再需要手动设置导出的列名称以及翻译，并且支持关联关系字段</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'id'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token operator">...</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 默认与上面的列相同</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">export</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>4.工具表单增加resetButton与submitButton方法</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 禁用重置和提交按钮</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">resetButton</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">submitButton</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>5.表单字段的<code v-pre>disable</code>以及<code v-pre>readOnly</code>方法增加参数控制是否启用</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 传 false 则不启用</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">disable</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>6.文件上传增加<code v-pre>withDeleteData</code>允许用户设置请求参数，并在上传接口以及删除接口中增加主键字段</strong></p>
<p>通过 <code v-pre>withDeleteData</code> 方法可以传递自定义参数到文件删除接口</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">file</span><span class="token punctuation">(</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">withDeleteData</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'key'</span> <span class="token operator">=></span> 'value<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p><strong>7.增加<code v-pre>embeds</code>表单禁止显示标题功能`</strong><br>
第二个参数传 <code v-pre>false</code> 则不显示标题</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">embeds</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'field'</span><span class="token punctuation">,</span> <span class="token constant boolean">false</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token operator">...</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>8.重新编写部分单元测试用例，以支持2.x用法</strong></p>
<h3 id="bug修复-22" tabindex="-1"><a class="header-anchor" href="#bug修复-22"><span>Bug修复</span></a></h3>
<ol>
<li>修复管理员详情页无法选中已有权限问题</li>
<li>修复 <code v-pre>admin:export-seed</code> 命令导出 <code v-pre>seeder</code> 类名异常问题</li>
<li>修复表单删除跳转异常问题</li>
<li>修复表单继续编辑跳转异常问题</li>
<li>修复父表与 <code v-pre>hasMany</code> 存在同样字段名称时无法保存父表字段问题</li>
<li>修复暗黑模式下选中子菜单样式异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/712" target="_blank" rel="noopener noreferrer">#712</a></li>
<li>修复表单 <code v-pre>block</code> 布局下表单动态显示功能无效问题 <a href="https://github.com/jqhph/dcat-admin/issues/723" target="_blank" rel="noopener noreferrer">#723</a></li>
<li>优化 <code v-pre>selectOptions</code> 层级结构显示，解决前缀呈现随层级深度指数增加问题 <a href="https://github.com/jqhph/dcat-admin/issues/618" target="_blank" rel="noopener noreferrer">#618</a></li>
<li>修复 <code v-pre>admin_view</code> 没有返回数据问题</li>
<li>修复 <code v-pre>select</code> 表单 <code v-pre>ajax</code> 以及 <code v-pre>load</code> 设置的链接不能带参数问题 <a href="https://github.com/jqhph/dcat-admin/issues/745" target="_blank" rel="noopener noreferrer">#745</a></li>
<li>修复表格行操作 <code v-pre>action</code> 的 <code v-pre>handle</code> 方法只能获取最后一行数据的 <code v-pre>id</code> 问题</li>
<li>修复 <code v-pre>list</code> 表单编辑页无法删除已有数据问题 <a href="https://github.com/jqhph/dcat-admin/issues/723" target="_blank" rel="noopener noreferrer">#759</a></li>
<li>修复 <code v-pre>embeds</code> 范围表单 <code v-pre>name</code> 属性错误问题</li>
</ol>
<p><strong>功能改进</strong></p>
<p>1.引入<a href="https://github.com/pie6k/jquery.initialize" target="_blank" rel="noopener noreferrer">jquery.initialize</a>组件，用于监听动态生成的页面元素并设置一个回调，下面来举一个简单的例子来演示用法：</p>
<p>在旧版本中，假如一个元素是<code v-pre>JS</code>动态生成的，如果我们需要对这个元素绑定一个点击事件的话，那么我们通常需要这么做</p>
<div class="language-html line-numbers-mode" data-highlighter="prismjs" data-ext="html" data-title="html"><pre v-pre class="language-html"><code><span class="line"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>selector<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>test<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></span>
<span class="line"></span>
<span class="line"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">></span></span><span class="token script"><span class="token language-javascript"></span>
<span class="line">Dcat<span class="token punctuation">.</span><span class="token function">ready</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// 需要先 off 再 on 否则页面刷新后会造成重复绑定问题</span></span>
<span class="line">    <span class="token function">$</span><span class="token punctuation">(</span>document<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">off</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> <span class="token string">'.selector'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> <span class="token string">'.selector'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面这种做法一来比较麻烦，需要先<code v-pre>off</code>再<code v-pre>on</code>；二来无法对动态生成的元素做一些特殊处理，例如你想在<code v-pre>.selector</code>生成后改变背景颜色，这个操作就没办法做到。</p>
<p>在这个版本中我们可以使用<code v-pre>Dcat.init</code>方法来监听元素动态生成，可以很方便的解决上面两个问题</p>
<div class="language-html line-numbers-mode" data-highlighter="prismjs" data-ext="html" data-title="html"><pre v-pre class="language-html"><code><span class="line"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>selector<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>test<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></span>
<span class="line"></span>
<span class="line"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">></span></span><span class="token script"><span class="token language-javascript"></span>
<span class="line">Dcat<span class="token punctuation">.</span><span class="token function">ready</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">// $this 是当前元素的jquery dom对象</span></span>
<span class="line">    <span class="token comment">// id 是当前元素的id属性，如果当前元素没有id则会自动生成一个随机id</span></span>
<span class="line">    Dcat<span class="token punctuation">.</span><span class="token function">init</span><span class="token punctuation">(</span><span class="token string">'.selector'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">$<span class="token keyword">this</span><span class="token punctuation">,</span> id</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token comment">// 修改元素的背景色</span></span>
<span class="line">        $<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">css</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token literal-property property">background</span><span class="token operator">:</span> <span class="token string">"#fff"</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 这里不需要 off 再重新 on，因为这个匿名函数只会执行一次</span></span>
<span class="line">        $<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token operator">...</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>得益于这个<a href="https://github.com/pie6k/jquery.initialize" target="_blank" rel="noopener noreferrer">jquery.initialize</a>组件的引入，在当前这个版本中我们对表单组件的前端代码也进行了优化，使其更容易支持<code v-pre>HasMany</code>这种动态生成的表单类型，大大降低了代码的复杂性。</p>
<p>2.Form::hasMany以及Form::array表单支持column和row布局</p>
<p>如果字段比较多，可以用<code v-pre>column</code>和<code v-pre>row</code>布局以节省空间</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">array</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'field'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">NestedForm</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">NestedForm</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token variable">$form</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name type-declaration">NestedForm</span> <span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token operator">...</span></span>
<span class="line">    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>3.配置过admin.auth.except参数的路由不需要验证权限 <a href="https://github.com/jqhph/dcat-admin/issues/673" target="_blank" rel="noopener noreferrer">#673</a></p>
<p>4.Form、Grid以及Show字段类增加when方法</p>
<p>用法示例，类似<code v-pre>Laravel QueryBuilder</code>的<code v-pre>when</code>方法</p>
<p>在表格中</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 当第一个参数的值为 真 时才会执行闭包的代码</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'title'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">when</span><span class="token punctuation">(</span><span class="token constant boolean">true</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name class-name-fully-qualified type-declaration">Grid<span class="token punctuation">\</span>Column</span> <span class="token variable">$column</span><span class="token punctuation">,</span> <span class="token variable">$value</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$column</span><span class="token operator">-></span><span class="token function">label</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>表单</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 当第一个参数的值为 真 时才会执行闭包的代码</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">text</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'email'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">when</span><span class="token punctuation">(</span><span class="token constant boolean">true</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token class-name class-name-fully-qualified type-declaration">Form<span class="token punctuation">\</span>Field<span class="token punctuation">\</span>Text</span> <span class="token variable">$text</span><span class="token punctuation">,</span> <span class="token variable">$value</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$text</span><span class="token operator">-></span><span class="token function">type</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'email'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>5.管理员模型增加canSeeMenu方法控制是否可见菜单</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">App<span class="token punctuation">\</span>Models</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Models<span class="token punctuation">\</span>Administrator</span> <span class="token keyword">as</span> Model<span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">Administrator</span> <span class="token keyword">extends</span> <span class="token class-name">Model</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 控制菜单是否可见，默认返回true</span>
<span class="line">     * </span>
<span class="line">     * <span class="token keyword">@param</span> <span class="token class-name"><span class="token keyword">array</span><span class="token punctuation">|</span><span class="token punctuation">\</span>Illuminate<span class="token punctuation">\</span>Database<span class="token punctuation">\</span>Eloquent<span class="token punctuation">\</span>Model</span> <span class="token parameter">$menu</span> 菜单节点</span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">bool</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">canSeeMenu</span><span class="token punctuation">(</span><span class="token variable">$menu</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token constant boolean">true</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>6.增加 admin_script、admin_style、admin_js、admin_css以及admin_require_assets函数</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 相当于 Admin::script</span></span>
<span class="line"><span class="token function">admin_script</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'console.log(xxx)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 相当于 Admin::style</span></span>
<span class="line"><span class="token function">admin_style</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'.my-class {color: red}'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 相当于 Admin::js() </span></span>
<span class="line"><span class="token function">admin_js</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'@admin/xxx.js'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 相当于 Admin::css() </span></span>
<span class="line"><span class="token function">admin_css</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'@admin/xxx.css'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 相当于 Admin::requireAssets() </span></span>
<span class="line"><span class="token function">admin_require_assets</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'@select2'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>7.简化动作(Action)的<code v-pre>JS</code>代码逻辑，去除记住<code v-pre>selector</code>功能</p>
<p><strong>BUG修复</strong></p>
<ol>
<li>修复表格 orderable 功能异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/674" target="_blank" rel="noopener noreferrer">#674</a></li>
<li>修复 JsonResponse methodIf 用法报错问题</li>
<li>修复表格、表单以及数据详情指定 <code v-pre>label</code> <a href="https://github.com/jqhph/dcat-admin/issues/684" target="_blank" rel="noopener noreferrer">#684</a></li>
<li>修复表格 <code v-pre>Grid::rows</code> 回调无法正常使用问题</li>
<li>修复widget添加<code v-pre>JS</code>代码异常导致部分类型的统计卡片异步加载功失效问题</li>
<li>修复表格行操作 getKey 方法异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/691" target="_blank" rel="noopener noreferrer">#691</a></li>
<li>修复当页面存在多个 select 表单时无法使用联动功能问题</li>
<li>修复表格删除数据后无法自动刷新页面问题</li>
</ol>
<h2 id="v2-0-6-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-6-beta"><span>v2.0.6-beta</span></a></h2>
<p>发布时间 2020/11/7</p>
<p>升级方法，逐步执行以下命令</p>
<div class="language-bash line-numbers-mode" data-highlighter="prismjs" data-ext="sh" data-title="sh"><pre v-pre class="language-bash"><code><span class="line"><span class="token function">composer</span> remove dcat/laravel-admin</span>
<span class="line"><span class="token function">composer</span> require dcat/laravel-admin:<span class="token string">"2.0.6-beta"</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--assets</span> <span class="token parameter variable">--force</span></span>
<span class="line">php artisan admin:publish <span class="token parameter variable">--migrations</span> <span class="token parameter variable">--force</span> <span class="token comment"># 表结构有变动</span></span>
<span class="line">php artisan migrate</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>功能接口破坏性变动</strong></p>
<p>1.<code v-pre>Form::tags</code>表单默认保存为<code v-pre>array</code>类型</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 需要自己转换保存到数据库的格式</span></span>
<span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">tags</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'tag'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">saveAsJson</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>2.默认禁用 session 中间件</p>
<p>3.<code v-pre>Form\Tree::disableFilterParents</code> 重命名为 <code v-pre>Form\Tree::exceptParentNode</code></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">tree</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'cate'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">exceptParentNode</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>4.文件上传表单部分方法名称调整</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 启用分块上传功能 disableChunked 更改为 chunked$form->image('avatar')->chunked(true);</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 启用自动保存字段值功能 disableAutoSave 更改为 autoSave$form->image('avatar')->autoSave(false);</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 启用删除文件功能 disableRemove 更改为 removeable$form->image('avatar')->removeable(false);</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>功能改进</strong></p>
<p>1.代码生成器增加字段拖动排序功能，此方法由小伙伴<a href="https://github.com/codingyu" target="_blank" rel="noopener noreferrer">@codingyu</a>贡献</p>
<p>2.菜单表增加<code v-pre>show</code>和<code v-pre>extension</code>字段，<code v-pre>show</code>字段用于控制是否显示菜单；<code v-pre>extension</code>字段用于标记是否为扩展菜单</p>
<p>3.<code v-pre>Form::table</code>、<code v-pre>Form::array</code>、<code v-pre>Form::embeds</code>表单支持关联关系字段</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">table</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile.options'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$form</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line"> <span class="token operator">...</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>4.增加 <code v-pre>Form::checkbox</code> 以及 <code v-pre>Form::radio</code> 表单选项竖排显示功能</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$form</span><span class="token operator">-></span><span class="token function">checkbox</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'xxx'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">inline</span><span class="token punctuation">(</span><span class="token constant boolean">false</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">options</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token operator">...</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>5.配置文件跳过登录以及权限验证功能允许配置路由别名</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token string single-quoted-string">'auth'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line"> <span class="token string single-quoted-string">'except'</span> <span class="token operator">=></span> <span class="token punctuation">[</span> <span class="token operator">...</span> <span class="token string single-quoted-string">'user.login'</span><span class="token punctuation">,</span> <span class="token punctuation">]</span><span class="token punctuation">,</span><span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>6.<code v-pre>Form\Row</code> 增加 <code v-pre>getKey</code> 以及 <code v-pre>model</code> 方法</p>
<p>7.优化表格过滤器select表单选中效果，默认不选中</p>
<p>8.表单tab布局优化</p>
<p><strong>BUG修复</strong><br>
1. 修复 <code v-pre>Form::checkbox</code> 选中/取消选中全部选项时动态显示表单功能无效问题<br>
2. 修复台湾繁体无法翻译默认菜单标题问题<br>
3. 修复 <code v-pre>NestedForm</code> 中的 <code v-pre>number</code> 字段输入值为 0 时会被过滤问题 <a href="https://github.com/jqhph/dcat-admin/issues/634" target="_blank" rel="noopener noreferrer">#634</a><br>
4. 修复模型树<code v-pre>RowAction</code>异步处理接口时获取主键报错问题<br>
5. 修复表格过滤器无法重置关联表字段搜索值问题 <a href="https://github.com/jqhph/dcat-admin/issues/650" target="_blank" rel="noopener noreferrer">#650</a><br>
6. 修复表格过滤器multipleSelect表单异常问题</p>
<h2 id="v2-0-5-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-5-beta"><span>v2.0.5-beta</span></a></h2>
<p>发布时间 2020/10/29</p>
<p>BUG修复</p>
<ol>
<li>修复表格搜索多个关联表字段sql错误问题 <a href="https://gitee.com/jqhph/dcat-admin/issues/I232T7" target="_blank" rel="noopener noreferrer">I232T7</a></li>
<li>修复<code v-pre>Form::datetimeRange</code>表单无法选择日志问题</li>
<li>修复无法添加多个<code v-pre>Form::table</code>表单字段问题 <a href="https://github.com/jqhph/dcat-admin/issues/627" target="_blank" rel="noopener noreferrer">#627</a></li>
<li>修复表格过滤器 MultipleSelectTable 中报错问题</li>
<li>修复表格规格筛选器样式异常问题</li>
</ol>
<h2 id="v2-0-4-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-4-beta"><span>v2.0.4-beta</span></a></h2>
<p>发布时间 2020/10/27</p>
<p>BUG修复<br>
1. 修复 admin_javascript_json 函数会自动空滤数组空值问题<br>
2. 修复数据表单使用 tab 布局报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/620" target="_blank" rel="noopener noreferrer">#620</a><br>
3. 修复扩展本地安装生成临时目录权限异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/625" target="_blank" rel="noopener noreferrer">#625</a><br>
4. 修复表单使用 html 方法设置视图存在 script 标签时报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/624" target="_blank" rel="noopener noreferrer">#624</a><br>
5. 修复数据详情使用关联关系（一对多）显示报错问题 <a href="https://github.com/jqhph/dcat-admin/issues/623" target="_blank" rel="noopener noreferrer">#623</a><br>
6. 修复 dropdown 下拉菜单计算显示位置异常问题 <a href="https://gitee.com/jqhph/dcat-admin/issues/I22S2N" target="_blank" rel="noopener noreferrer">#I22S2N</a></p>
<h2 id="v2-0-3-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-3-beta"><span>v2.0.3-beta</span></a></h2>
<p>发布时间 2020/10/27</p>
<p>BUG修复<br>
1. 修复表单行内编辑显示返回信息异常问题<br>
2. 修复<code v-pre>admin.auth.remember</code>设置无效问题 <a href="https://github.com/jqhph/dcat-admin/issues/613" target="_blank" rel="noopener noreferrer">#613</a><br>
3. 修复<code v-pre>editor</code>表单中文翻译异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/611" target="_blank" rel="noopener noreferrer">#611</a><br>
4. 修复<code v-pre>Filter::scope</code>选择筛选项不会过滤分页参数问题<br>
5. 修复表单事件拦截相关问题<br>
6. 修复树形表单使用异常问题 <a href="https://github.com/jqhph/dcat-admin/issues/619" target="_blank" rel="noopener noreferrer">#619</a></p>
<p>功能改进<br>
1. 增加跳过权限和登录验证的配置方式<br>
2. 扩展service provider增加middleware和路由排查注册功能<br>
3. 批量操作change事件监听优化<br>
4. 增加<code v-pre>RowSelector</code>健壮性, 以避免遇到<code v-pre>json</code>数组类型字段无法处理而报错 <a href="https://github.com/jqhph/dcat-admin/pull/609" target="_blank" rel="noopener noreferrer">#609</a></p>
<h2 id="v2-0-2-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-2-beta"><span>v2.0.2-beta</span></a></h2>
<p>发布时间 2020/10/21</p>
<p>BUG修复<br>
1. 修复代码生成器生成控制器文件命名空间异常问题 #600<br>
2. 修复配置文件logo路径错误问题<br>
3. 修复表格关联字段搜索无效问题<br>
4. 修复模型树行操作生成选择器重复问题<br>
5. 修复访问无权限页面报错问题<br>
6. 修复表格过滤器multipleSelect无法选中关联表字段值问题 #603<br>
7. 修复表单tab布局无效问题 #605</p>
<p>功能改进<br>
1. Auth\Permission移至Http目录<br>
2. 数据表json字段改成text<br>
3. 增加登录账号密码错误翻译<br>
4. 增加 admin_javascript_json 函数，使大部分组件配置支持传递JS代码<br>
5. Admin::color 增加暗黑模式颜色</p>
<h2 id="v2-0-1-beta" tabindex="-1"><a class="header-anchor" href="#v2-0-1-beta"><span>v2.0.1-beta</span></a></h2>
<p>发布时间 2020/10/20</p>
<p>BUG修复</p>
<ul>
<li>修复数据表格过滤搜索BUG #599</li>
<li>修复代码生成器生成控制器基类命名空间错误问题 #600</li>
</ul>
<p>功能改进</p>
<ul>
<li>代码生成器增加页面标题以及面包屑翻译功能</li>
<li>异常处理优化</li>
<li>增加 admin_setting_array 函数</li>
</ul>
</div></template>


